Create a List of primitive int?

In Java the type of any variable is either a primitive type or a reference type. Generic type arguments must be reference types. Since primitives do not extend Object they cannot be used as generic type arguments for a parametrized type. Instead use the Integer class which is a wrapper for int: List<Integer> list = new ArrayList<Integer>(); If your using … Read more

Type List vs type ArrayList in Java

Almost always List is preferred over ArrayList because, for instance, List can be translated into a LinkedList without affecting the rest of the codebase. If one used ArrayList instead of List, it’s hard to change the ArrayList implementation into a LinkedList one because ArrayList specific methods have been used in the codebase that would also require restructuring. You can read about the List implementations here. You may start with an ArrayList, but soon after discover that … Read more

List of Arrays in Java

Firstly, you can’t do new List(); it is an interface. To make a list of int Arrays, do something like this : List<int[]> myList = new ArrayList<int[]>(); P.S. As per the comment, package for List is java.util.List and for ArrayList java.util.ArrayList