一個類不允許有兩個重載方法,可以在類型擦除後使用相同的簽名。
class Box {
//Compiler error
//Erasure of method print(List<String>)
//is the same as another method in type Box
public void print(List<String> stringList) { }
public void print(List<Integer> integerList) { }
}
上一篇:
Java泛型不能使用異常
下一篇:無