Java 泛型 - 无重载



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

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) { }
}
广告
© . All rights reserved.