Is there a difference between Enumeration<? extends ZipEntry> and Enumeration<ZipEntry>? If so, what is the difference?
Is there a difference between Enumeration<? extends ZipEntry> and Enumeration<ZipEntry>? If so, what is
Share
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.
There’s no practical difference in terms of what you can do when you’ve got one of them, because the type parameter is only used in an ‘output’ position. On the other hand, there’s a big difference in terms of what you can use as one of them.
Suppose you had an
Enumeration<JarEntry>– you couldn’t pass this to a method which tookEnumeration<ZipEntry>as one of its arguments. You could pass it to a method takingEnumeration<? extends ZipEntry>though.It’s more interesting when you’ve got a type which uses the type parameter in both input and output positions –
List<T>being the most obvious example. Here are three examples of methods with variations on a parameter. In each case we’ll try to get an item from the list, and add another one.For more details, read: