Originally posted by Peter Chase:
Your class Inserter just takes a plain List, so you can put any type of item into it. Hence the Inserter class compiles fine.
Actually, I'd expect a warning here, about using a raw List. That's exactly what my Eclipse is doing:
Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized
The class that uses Inserter is passing a List<Integer> to a method that takes a plain List. I would have expected a compiler warning there.
Why? A List<Integer> is still a List, so it is a valid parameter.
anveshana, I think
you should check your compiler (
IDE) settings, I think it is ignoring some warnings it shouldn't ignore.