I am trying to create a 2d array list but it is giving me a compiler error pointing at the first line of the function. I don't really get what is causing the problem. I am pretty good in C++ but Java has some new rules that I am trying to learn. Does anyone see a problem here?
Code:
void addToList(int[] a, int j, int i, int N)
{
ArrayList< ArrayList<int> > perms = new ArrayList<ArrayList<int>>();
for(int x = 0; x < N; x++) {
perms.add(new ArrayList<int>());
perms.get(perms.size()-1).add(a[x]);
System.out.print(a[x]);
}
System.out.println(" swapped(" + j + ", " + i + ")");
} // addToList()
Error:
MiniMaxTree.java:119: unexpected type
found : int
required: reference
ArrayList< ArrayList<int> > perms = new ArrayList<ArrayList<int>>();
^
MiniMaxTree.java:119: unexpected type
found : int
required: reference
ArrayList< ArrayList<int> > perms = new ArrayList<ArrayList<int>>();
Thanks in advance!