| | |
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: 442 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for Java
6 android api apple applet application arguments array arrays automation binary bluetooth bold byte c++ chat class classes client code component coordinates database datagram doctype draw eclipse educational error event exception file fractal froglogic game givemetehcodez graphics gui helpwithhomework html ide ideas image ingres input integer internet intersect ip j2me java javaexcel javaprojects jmf jni jpanel jtextarea julia linux list loop map method methods mobile netbeans newbie nextline number object oracle pong print problem program programming project recursion recursive scanner screen sell server set size sms socket sort sql string swing test threads time transfer tree user web websites windows






