English 中文(简体)
Java Generics - No Overload
  • 时间:2024-11-05

Java Generics - No Overload


Previous Page Next Page  

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
   pubpc void print(List<String> stringList) { }
   pubpc void print(List<Integer> integerList) { }
}
Advertisements