首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

超类、子类接口实现,泛型数组排序综合使用遇到的有关问题

2013-02-24 
超类、子类接口实现,泛型数组排序综合使用遇到的问题我实现了几个类:Person、Employee extends Person、Stude

超类、子类接口实现,泛型数组排序综合使用遇到的问题
我实现了几个类:
Person、Employee extends Person、Student extens Person、Manager extends Employee
在书上看到,实现接口的方法:
1、将类声明为实现给定的接口;
2、对接口中的所有方法进行定义。
我在声明的时候(Class Person implements comparable)
报错:The type Person must implement the inherited abstract method Comparable.compareTo(Object),于是我认为无需声明,所以去掉了声明的部分。

在Person类中定义接口的compareTo方法:

                            
[解决办法]
引用:
2、对接口中的所有方法进行定义。
我在声明的时候(Class Person implements comparable)
报错:The type Person must implement the inherited abstract method Comparable.compareTo(Object),于是我认为无需声明,所以去掉了声明的部分。
报错……


必须声明,如果person类不想实现这个方法,直接把Persion类定义成Abstract就行了

热点排行