Java 泛型无重载

创建于 2024-12-02 / 32
字体: [默认] [大] [更大]

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

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


0 人点赞过