This passes compilation:
LinkedList> list1 = new LinkedList ();
This doesn't:
LinkedList
i.e. a LinkedList>
variable can be assigned any LinkedList
. A LinkedList
variable can only be assigned a LinkedList
(or a raw LinkedList
, which is not advised to use).
On the other hand the following add
:
LinkedList> list1 = new LinkedList ();
list1.add("x");
doesn't pass compilation, while the following does:
LinkedList