| | |
ArrayList<ArrayList<int>> compiler problem
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 64
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
Views: 449 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for Java
-xlint android api apple applet application arguments array arrays automation binary block bluetooth chat class classes client code compile component database developmenthelp draw eclipse encode error event exception file fractal freeze game gameprogramming givemetehcodez graphics gui helpwithhomework html ide image input integer iphone j2me j2seprojects java javac javaprojects jmf jni jpanel julia lego linux list loop loops mac map method methods mobile netbeans newbie notdisplaying number object online oracle print problem program programming project recursion scanner screen server set singleton size sms socket sort sql string swing system template test textfields threads time title transfer tree tutorial-sample update windows working






