• Post Reply Bookmark Topic Watch Topic
  • New Topic

Generics & overriding  RSS feed

Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody, I have this piece of code:

As soon as I parametrize the DerivedClass like this:

everything flips upside down - the newMethod1 overriding with List<Integer> becomes illegal and the newMethod2 perfectly-matching-overriding becomes 100% legal. How come that some abstract class generic parameter T has influence on overriding methods that don't even use it? Does the Java compiler automatically treat subclasses that extend generic super classes without declaring generic parameter as legacy code? If so, then why is List<Integer> allowed at all in DerivedClass, if it is supposed to be pre-Java-5?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!