| | |
ArrayList<ArrayList<int>> compiler problem
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 61
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 |
2dgraphics account android api apple applet application array arrays automation banking binary binarytree bluetooth chat chatprogramusingobjects class classes client code component data database derby design draw eclipse encryption error event exception fractal game givemetehcodez graphics gui html ide if_statement image inheritance input integer interface j2me java javadesktopapplications javaprojects jlabel jni jpanel jtextfield julia linux list loop map method methods midlethttpconnection mobile monitoring netbeans newbie nullpointerexception open-source oracle print printing problem program programming project property recursion reference ria scanner screen search server set size sms sort sourcelabs splash sql static stop string swing testautomation threads time tree ui unicode validation windows






