NingG +

Java中集合类简介

初步想到几点:

常见问题

场景:统计一组word中,各个word出现的频率,并按序输出

两条路:

第三方jar包guava的排序操作,示例代码如下:

Object[] result = null;
String[] stringArray = {"a", "b", "c", "a", "d", "d", "e", "f", "f", "f"};
List<String> listOfStr = Arrays.asList(stringArray);
result =  Multisets.copyHighestCountFirst(ImmutableMultiset.copyOf(stringArray)).elementSet().toArray();
System.out.println(Arrays.toString(result));

具体参考:

Top