What is the difference between the following ways of declaring ArrayList
:
ArrayList<String> list = new ArrayList();
ArrayList list = new ArrayList<String>();
Both declarations compile, altough the first one shows warning for unchecked type.
So, why do programmers are using
ArrayList<String> list = new ArrayList<String>();
instead of the shorter version
ArrayList list = new ArrayList<String>();