Consider the following API method taken from Shiro\'s org.apache.shiro.subject.PrincipalCollection interface but probably present in other libraries as well:
A use-case that I can think of as to why Collection
is not considered as Collection>
is let say we have a instance of ArrayList
Now if the instance is of type ArrayList
or ArrayList
or ArrayList
, you can add that type only(type checking). ArrayList>
is not equivalent to ArrayList
.
But with only ArrayList
, you can add object of any type. This may be one of the reason why compiler is not considering ArrayList
as ArrayList>
(type checking).
One more reason could be backward compatibility with Java version that didn't have generics.