Comparator 接口內(nèi)容
我在查看Comparator接口文件的時(shí)候 發(fā)現(xiàn)里面除了CompareTo接口方法之外 ?還有很多有方法體的其他方法如
這是為什么?接口中不是不能有方法的實(shí)現(xiàn)嗎?
我在查看Comparator接口文件的時(shí)候 發(fā)現(xiàn)里面除了CompareTo接口方法之外 ?還有很多有方法體的其他方法如
這是為什么?接口中不是不能有方法的實(shí)現(xiàn)嗎?
2019-07-30
舉報(bào)
2019-10-14
接口中確實(shí)不能有方法的實(shí)現(xiàn),但可以進(jìn)行接口回調(diào),
比如我定義一個(gè)human接口和一個(gè)young類,
interface human
{
void Output();
}
class young implements human
{
????public young(){}
????public void Ouput(){}
}
human h=new young();
h.Output();
這樣做是可以的,