ArrayList declaration Java
List<String> strList1 = new ArrayList<String>();
ArrayList<String> strList2 = new ArrayList<String>();
ArrayList class implements the
It is usually a good practice to declare an object of the type of the interface and of course instantiate it using an implementation of that interface.
This way, you can change the implementation when needed, but the declared type stays unchanged. This way, you could avoid modifying too much code especially in the methods getting the variable as a parameter. The method keeps getting a
List as a parameter, not a certain implementation.