JAVA day15
TreeSetDemo.java
1 public int compareTo(Object obj) 2 { 3 if(!(obj instanceof Student)) 4 throw new RuntimeException("不是学生对象"); 5 Student stu = (Student)obj; 6 7 if((this.age == stu.age) && !this.name.equals(stu.name)) 8 return (this.name.compareTo(stu.name)); 9 else 10 return (this.age-stu.age); 11 } 12
__________________________________________________________
shoobie do lang lang ^^