What if I want to have a variable, say a List, which can be instantiated with any Type?
So, given:
List list;
I could do any of these:
list = new ArrayList<String>();
list = new Vector<Integer>();
list = new LinkedList<HashMap>();
Edit: Alternatively, I may be using a library that returns a raw List. For example, in Hibernate:
List result = session.createQuery( "from Event" ).list();
Eclipse gives me this warning when I want to use List list
:
List is a raw type. References to generic type
List<E>
should be parameterized
Why should this be avoided?