Since the caller can call removeeither containswith any type of object, and the code will still execute just fine. A compile-time contract that uses the collection type parameter simply guarantees * that everything in the collection will be of the given type. It doesn't matter if you ask if it contains an object of another type.
* Nitpicker Corner, I know that Java generics really are not a guarantee. I suppose more syntactic sugar.
source
share