List listOne = new LinkedList<Shxx>();
List<Shxx> listTwo = new LinkedList<Shxx>();
List listThree = new LinkedList();
List<Shxx> listFour = new LinkedList();
views:
56answers:
2List listOne = new LinkedList<Shxx>();
Throws away the type information, might as well not use generics at all.
List<Shxx> listTwo = new LinkedList<Shxx>();
Correct full use of generics, provides type safety.
List listThree = new LinkedList();
No use of generics (i.e. pre Java 5 code), no type safety.
List<Shxx> listFour = new LinkedList();
Will cause a compiler warning, but otherwise OK because the list can only be used through the typesafe reference and is initially empty. Shouldn't be done anyway because if you ignore compiler warnings concerning the use of raw types, you could also be ignoring others that are not as benign as this one. The best way to get the maximum type safety out of generics is to eliminate all related compiler warnings.
listOne and listThree will only be usable in code as lists of objects (additionnally, your IDE may show warnings for both, as instanciation of listOne implies an unchecked use of a checked collection, while instanciation of listThree is a raw use of what should be a checked collection).
For both theses lists, you'll be able to add any kind of object (String as an archetypal example).
listTwo is declared as a classical List of Shxx.
For this list, compiler will only allow you to add items of the Shxx type.
Declaration of listFour compiles, and makes list usable (like listTwo) as a List of Shxx (but I wouldn't recommand such writing).
Finally, although these lists won't be usable in the same fashion in your declared code, you have to know that they'll all be equivalent at Runtime (but you theorically won't be able to overcome those generics limitations before a long time).