The first two use raw types. This means that your list is not safe for all types. The compiler will allow you to store integrals inside, even if your intention is to have a list of strings. The compiler will generate a warning that you should not ignore.
The third is correct. It tells the compiler that you intend to use a list of strings and that the specific implementation you have selected is an ArrayList. If you change your mind later and want to use LinkedList, this line of code will be the only one you need to change.
The fourth tells the compiler that your program does not need only a list. He needs this list as an ArrayList. This is normal if your code really needs to call methods specific to ArrayList and they are not in the List interface. But in 99.9% of cases this is not so, and you should prefer the third.
The last two declare the variable and initialize it to zero, rather than creating a list. This is a designer smell. Before using the list, you need to make sure that it is not zero. It is much safer to initialize it with the correct list.
source share