Java在实现Comparator接口时,只实现一个compare方法,为什么加了编译可以通过,实现接口不是要把所有方法都实现吗?
class PairComp implements Comparator{
public int compare(int[] a,int[] b){
int com_h = a[0] - b[0];
return com_h == 0 ? b[1] - a[1]:com_h;
}
}
你去看看这个接口有几个方法