CommentMay 10, 2017
As suggested, always try to go with List<Integer> list = new ArrayList<Integer>(); . This Design Pattern principle is called Program to an interface, not an implementation . This holds true for all types of objects instantiation as “Program to an interface ” really means “Program to a supertype. ” Read Chapter 1 from Head First Design Patterns to get a better idea. Checkout more examples here .