When I try to override a method that takes a List
, I get the following compile error.
Multiple markers at this
The error you have pointed out is obviously because of the @Override annotation. When validating annotations (which I presume must happen at the very early stage of compiling process) the type erasure hasn't occurred. So the types List is not same as List and you get the warning. But even without that annotation I get an error
name clash: getname(java.util.List) in child and getname(java.util.List) in parent have the same erasure, yet neither overrides the other
class child extends parent{`.
This error clearly says that they have the same erasure but still neither over rides. So Java in principle doesn't allow it.
I can understand it will lead to many problems/confusions if allowed. For e.g. if someone makes a call new Child().get_name( new List
, it can't be resolved to the Child method which will break the concept of over riding. So it is correct that it is not allowed.