问一下,我这么简单的语句哪里错啦,迷糊了
import java.util.Arrays;
import java.util.Comparator;
public class more {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] s=new int[]{3,6,0,1,6,2,33};
Arrays.sort(s,new Lower());
for(int i=0;i <s.length;i++){
System.out.println(s[i]);
}
}
}
class Lower implements Comparator <Integer> {
public int compare(Integer s1,Integer s2){
return s1> s2?1:(s1==s2?0:-1);
}
}
------解决方案--------------------如果你给sort传入一个(s,new Comparator <Integer> )对象,则s必须是Integer数组,而你的s是一个int数组类型.