So I can't seem to figure out the difference between these two code snippets, or when one would be preferred over the other. Snippet #1
public static void main(String[] args) {
List testList = new ArrayList();
testList.add(new Integer(6));
String string = (String) testList.get(0);
}
Snippet #2
public static void main(String[] args) {
ArrayList testList = new ArrayList();
testList.add(new Integer(6));
String string = (String) testList.get(0);
}
My interpretation was that in snippet 1, a List named testList is being assigned to an ArrayList object. And in snippet 2 an ArrayList named testList is being assigned to an ArrayList object. However that just doesnt make sense to me.
Side question: Is one of the two a preferred standard?