Click here to Skip to main content
15,902,777 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi how do I find similiar string in an arraylist and count the duplicated strings
Posted
Comments
Sergey Alexandrovich Kryukov 19-Nov-14 3:12am    
You need to define "similar", to start with...
—SA

Once you defined a 'similitude test', that is a method establishing if the passed strings are similar or not you could apply such a method to the string pairs in your list and increment the counter whenever the test is passed.
Writing a method testing the similarity of the strings it is not a trivial task and heavily depends (as noted by Sergey) on your requirements.
 
Share this answer
 
sample code:
Java
List<string> list = new ArrayList<string>();
list.add("aaa");
list.add("bbb");
list.add("aaa");

Set<string> unique = new HashSet<string>(list);
for (String key : unique) {
    System.out.println(key + ": " + Collections.frequency(list, key));
}</string></string></string></string>

refer : http://stackoverflow.com/questions/5211194/count-occurences-of-words-in-arraylist[^]
 
Share this answer
 
Comments
TorstenH. 19-Nov-14 4:26am    
Please do not post homework kind of stuff.
They should think themself.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900