Overloading Java function with List<> parameter

前端 未结 6 1346
猫巷女王i
猫巷女王i 2021-02-02 15:19

I have 2 classes

public class Customer{
  ...
  public String getCustomerNumber();
  ...
}

public class Applicant{
   ....
   private Customer c;
   public Cust         


        
6条回答
  •  無奈伤痛
    2021-02-02 15:35

    Generics have what is known as type erasure - List and List are the same type, the compiler just places compile-time restrictions on what you can do with them.

    You could check the type of the first object in the list and call a (differently-named) internal method based on that.

提交回复
热议问题