The method sort(int[]) in the type Arrays is not applicable for the arguments (int[], Collections.reverseOrder())
Java中Arrays.sort()增加Comparator时,需要注意传入数组的格式
不能够使用int声明的数组,必须使用Integer声明的数组
例如
如果直接使用int创建的数组就会报错

在Java中使用Arrays.sort()方法结合Comparator进行排序时,若使用int数组将引发错误。文章详细解释了这一现象的原因,并提供了正确的解决方案,即使用Integer数组来避免编译错误。
The method sort(int[]) in the type Arrays is not applicable for the arguments (int[], Collections.reverseOrder())
Java中Arrays.sort()增加Comparator时,需要注意传入数组的格式
不能够使用int声明的数组,必须使用Integer声明的数组
例如
如果直接使用int创建的数组就会报错

798
3840
486
2万+

被折叠的 条评论
为什么被折叠?