No doubt that Generics is one of the most confusing topics in Java and you can easily forget concepts and rules, especially, if you don't code Java everyday. For example, both List> and List looks similar but there is a subtle difference between them, the List> is basically a list of any type, you can assign a list of String i.e. List or list of Integer i.e. List to it. You see the point, it uses the unbounded wildcard >, which means any type. It provides it the much needed Polymorphism require while writing Generic methods. Basically, if your method has a type List> which means you can pass any type of List to it but remember the type is unknown, until you assign it i.e. List> myList = new List().
This post first appeared on Javarevisited: Blog About Java Programmin, please read the originial post: here