无涯教程-Java泛型 - 不允许 重载

44 阅读1分钟

一个类不允许具有两个在类型擦除后可以具有相同签名的重载方法。

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) { }
}

参考链接

www.learnfk.com/java-generi…