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