譬如
public class Entry<K,V> {
K key;
V value;
public Entry(K key, V value){
this.key = key;
this.value = value;
}
boolean equals(Entry e){
return (this.key == e.getKey() && this.value == e.getValue());
}
}
这里面这个 equals 函数里的 Entry 加<>和不加<>有区别吗? 然后这三种情况 1 不加 2 加<> 3 加<K,V> 什么时候该用哪个有什么规则吗? 是不是加<K,V>是最保险的?