I have the following code:
List<int> intList = new ArrayList<int>();
for (int index = 0; index < ints.length; index++)
{
intList.add(ints[index]);
}
It gives me an error…
Syntax error on token "int", Dimensions expected after this token
The error occurs on the line starting with List. Can someone explain why I am getting the error?
Generics in Java are not applicable to primitive types as in
int. You should probably use wrapper types such asInteger:And, to access a
List, you need to useints.get(index).