It's not at all the same thing. In one case you're adding a Dog
, in the other case you're adding an Animal
.
In both cases you only know that Dog
s are allowed, so the second case fails.
To answer your second question, there is a difference, and you should always use the second version. (In Java 7+, however, you can request the compiler to infer the generic type for you by writing new ArrayList<>()
.)