Java examples for java.lang:String Algorithm
find Max Occurrence In String List
//package com.java2s; import java.util.List; import java.util.Collections; public class Main { /**/*w w w . java 2 s .co m*/ * */ public static String findMaxOccurrenceInList(List<String> list) { int curr = 0, max = 0; String maxKey = ""; if (list.size() == 0) { return maxKey; } for (String key : list) { curr = Collections.frequency(list, key); if (max < curr) { max = curr; maxKey = key; } } return maxKey; } }