Set<String> uniqueSet = new HashSet<String>(list);
for (String temp : uniqueSet) {
System.out.println(temp + ": " + Collections.frequency(list, temp));
}
Above is the java code that i got from one of the forum, the for loop was looking little mysterious, can some one please explain.