以下程序不能实现排序 哪里错了 帮忙看下
public class paixu implements Comparator{
int f;
public paixu(int s ){
f=s;
}
public String toString (){
return ""+f;
}
public int compare(Object o1, Object o2) {
int s;
int s1;
s=((paixu)o1).f;
s1=((paixu)o1).f;
return (s<s1?-1:(s==s1?0:1));
}
public static void main(String[] args) {
paixu l[]={new paixu(1),new paixu(6),new paixu(8),new paixu(3)};
Arrays.sort(l,new paixu(0));
for(int i=0;i<l.length;i++)
System.out.print(l[i]);
}
}
public class paixu implements Comparator{
int f;
public paixu(int s ){
f=s;
}
public String toString (){
return ""+f;
}
public int compare(Object o1, Object o2) {
int s;
int s1;
s=((paixu)o1).f;
s1=((paixu)o1).f;
return (s<s1?-1:(s==s1?0:1));
}
public static void main(String[] args) {
paixu l[]={new paixu(1),new paixu(6),new paixu(8),new paixu(3)};
Arrays.sort(l,new paixu(0));
for(int i=0;i<l.length;i++)
System.out.print(l[i]);
}
}
s1=((paixu)o1).f;
目标锁定这2句 自己在仔细看看
s1=((csdntest)o1).f;
改成s1=((csdntest)o2).f;