我想我已经明白了sort()了;但是class Employee implements Comparable
呢?Employee好象没有实现Comparable
里的任何方法啊!public int compareTo(Object otherObject)方法还是在Employee里声明的呢。
我的意思是Employee并没有继承Comparable里的方法啊!
那为什么还要implements Comparable呢?????

解决方案 »

  1.   

    public int compareTo(Object otherObject)方法是cmparable里的一个方法,这里只是覆盖了那个方法实现你这个排序中的比较,如果不implements Comparable,那些了这个方法是没意义的,没有地方会去调用的
      

  2.   

    就算是继成interface里的方法也是要声明的啊,有什么不对。
      

  3.   

    Comparable是接口呀,里面的方法
      int compareTo(Object otherObject)只是申明,没有实现的代码的。
    所以你的 Employee 类中需要
       public int compareTo(Object otherObject)来实现接口。