mat*_*th5 3 java arrays collections spring-boot
如何将 int 数组转换为 SortedSet?
以下不起作用,
SortedSet lst= new TreeSet(Arrays.asList(RatedMessage));
Run Code Online (Sandbox Code Playgroud)
错误:
无法在 java.util.TreeMap.compare(TreeMap.java:1290) 处转换为 java.lang.Comparable
public static NavigableSet<Integer> convertToSet(int... arr) {
return Arrays.stream(arr).boxed().collect(Collectors.toCollection(TreeSet::new));
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
435 次 |
| 最近记录: |