what is the difference between these two in java? I always get confused when using the <> syntax. when is better to create a generic class than to use generic methods from collection classes?
2 Answers
Collection classes use generics (a kind of parametric polymorphism) since Java 5, so users of the library don't have to cast the elements of the collection themselves anymore.
Therefore, collection classes are a nice example how generics can be used to make developers lives easier, apart from that generics and collection are completely different topics.