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
Sergey Alexandrovich Kryukov 19-Nov-14 3:12am    
You need to define "similar", to start with...

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:
List<string> list = new ArrayList<string>();

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

refer :[^]
Share this answer
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