Java Generics - No Overload



A class is not allowed to have two overloaded methods that can have the same signature after type erasure.

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