-2
默认排序方法在Java中不适用于我。用于排序的Java比较器不起作用
int[] nums = {11,14,15,10};
Arrays.sort(nums, new Comparator<Integer>() {
public int compare(Integer a, Integer b) {
// compare code here
}
});
我得到的错误是
"The method sort(int[]) in the type Arrays is not applicable for the arguments (int[], new Comparator<Integer>(){})"
我觉得我现在是愚蠢的。
int []不是Integer [],而int不是Integer。 – user2357112
您无法指定Comparator通过'Arrays.sort'对int []进行排序。 – saka1029
也许更具体的https://stackoverflow.com/questions/12654600/descending-order。假设在过去的某个时间点,世界上的某个人和你有同样的问题,并从那里开始工作。 – Dukeling