import java.util.Collections;
import java.util.Comparator;
import java.util.Vector;
public class TestClass {
public static void main(String[] args){
Vector
v.add(5);
v.add(3);
v.add(2);
v.add(1);
v.add(4);
Comparator
Collections.sort(v,cm );
for(Integer x :v)
System.out.print(x + " ");
}
}
class MyComparator implements Comparator
public int compare(Integer i1, Integer i2) {
if (i1 > i2) return -1;
else if (i1 == i2) return 0;
else return 1;
}
}
public void NumverShort(Vecher
for(int i=0;i
int temp=ve.get(x);
ve.get(x)=ve.get(x+1);
ve.get(x+1)=temp;
}
}
}
}
可以直接调用Arrays.sort(v);应该就可以了,不过你这定义的是数组吗?我也是新手,请多指教.