new ArrayList<int>() failing in Java

Generics in Java are not applicable to primitive types as in int. You should probably use wrapper types such as Integer:

List<Integer> ints = ...

And, to access a List, you need to use ints.get(index).


You can only use an Object type within the <> section, whereas you're trying to use a primitive type. Try this...

List<Integer> intList = new ArrayList<Integer>();

You then need to access the values using intList.get(index) and intList.set(index,value) (and also intList.add(value) as you are trying to do)


you should use Integer instead of int because lists requires object not primitive types. but u can still add element of type int to your Integer list