| | |
ArrayList<ArrayList<int>> compiler problem
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 63
Reputation:
Solved Threads: 1
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:
Error:
Thanks in advance!
Code:
Java Syntax (Toggle Plain Text)
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!
Last edited by chunalt787; Oct 27th, 2009 at 2:37 pm.
![]() |
Similar Threads
- Problem in counting number of ArrayList object in ArrayList (Java)
- how to display ArrayList of ArrayList in jsp page using tags in struts (JSP)
- It Prints nothing from the ArrayList? (Java)
- Unable to pass arraylist data from servlet to jsp. (JSP)
- ArrayList<MyClass>, help writing MyClass (Java)
- ArrayList of ArrayList (Java)
- Need Help with ArrayList sorting (Java)
Other Threads in the Java Forum
- Previous Thread: Jlist Renderer
- Next Thread: LAN Video Conference System
| Thread Tools | Search this Thread |
-xlint android api applet application array arrays automation bi binary blackberry block bluetooth chat class classes client code compile compiler component database developmenthelp draw eclipse error event exception fractal freeze game gameprogramming givemetehcodez graphics gui html ide image input integer j2me j2seprojects java javac javaprojects jetbrains jni jpanel jtable julia learningresources lego linux list login loop loops mac map method methods mobile netbeans newbie notdisplaying number online oracle page print problem program programming project qt recursion scanner screen server set singleton size sms sort sql string swing system template textfields threads time title tree tutorial-sample update variablebinding windows working xor






