I recommend using Java8 Stream to deal with many collections, which is very simple and easy to understand.
In fact, your question is to classify the strings in the collection and count the number. Stream only uses simple code to complete complex operations, and the code is as follows: list <; String> ? list? =? Arrays.asList("day",? "walipo",? "day",? "walipo",? "legeand",? "day",? "douwbo",? "day",? "day");
Map< String,? Long> ? collect? =? list.stream().collect(Collectors.groupingBy(Function.identity(),? Collectors.counting()));
System.out.println(collect);
the last returned Map takes the string as the key and the value as its number.