Are the following method declarations,
public void testMethod(ArrayList<T extends Animal> list)
and
public <T extends Animal> void testMethod(ArrayList<T> list)
the same?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The difference is that the former does not compile, while the latter does. Is it what you were asking?
If you meant difference between:
and
then the difference is that in first case you cannot refer to actual type of
ArrayListelements, while in second case you can.Probably, the difference will be more obvious if we will consider the following two cases:
and
In the first case, first argument is an
ArrayListof some type that extendsAnimal, the second argument is anArraylistor some (probably other) type that extendsAnimal.In the second case, both arguments are
ArralLists of the same type that extendsAnimal.