日期:2014-05-20  浏览次数:20750 次

新手求助 关于javaee对象数组排序的问题
mport java.util.Arrays;

class Cla implements Comparable {
int num;
String name;

Cla(int num, String name) {
this.num = num;
this.name = name;
}

public String toString() {
return "num:" + num + ",姓名:" + name;
}

public int compareTo(Object o) {
Cla s = (Cla) o;
return num > s.num ? 1 : (num == s.num ? 0 : -1);
}

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Cla[] s = { new Cla(2, "zhang"), new Cla(1, "li"), new Cla(5, "z") };
Arrays.sort(s);
for (int i = 0; i < s.length; i++) {
System.out.println(s);
}

}

}
为什么结果是:
[La.Cla;@de6ced
[La.Cla;@de6ced
[La.Cla;@de6ced


------解决方案--------------------
s ->s[i]
------解决方案--------------------
s[i]