Use a HashMap. Here is a simple implementation
List strings = new ArrayList();
strings.put("stack", "overflow", "stack", "yahoo", "google", "msn", "MSN", "stack", "overflow", "user");
Map counts = new HashMap();
for (String str : strings) {
if (counts.containsKey(str)) {
counts.put(str, counts.get(str) + 1);
} else {
counts.put(str, 1);
}
}
for (Map.Entry entry : counts.entrySet()) {
System.out.println(entry.getKey() + " = " + entry.getValue());
}