Results 1 to 6 of 6
Thread: Arraylist of arraylists
- 03-31-2012, 10:52 PM #1
Member
- Join Date
- Mar 2010
- Posts
- 24
- Rep Power
- 0
- 03-31-2012, 10:56 PM #2
Re: Arraylist of arraylists
Does the code compile?
like the uper?Last edited by Norm; 03-31-2012 at 10:59 PM.
If you don't understand my response, don't ignore it, ask a question.
- 03-31-2012, 11:07 PM #3
Member
- Join Date
- Mar 2010
- Posts
- 24
- Rep Power
- 0
Re: Arraylist of arraylists
I need to declare an arraylist that holds arraylists of the following kind.
Arraylist stringArraylist<string>;
I didnt try because i dont know how to declare it.
- 03-31-2012, 11:14 PM #4
Re: Arraylist of arraylists
Have you ever written an ArrayList that holds a String? You define the data type first followed by the name to be given to the object .
The symbol: String can be replaced with any other class name.
Check out the tutorial:
http://docs.oracle.com/javase/tutori...ybigindex.html
Find Generics and read on. There are two places to read in.Last edited by Norm; 03-31-2012 at 11:17 PM.
If you don't understand my response, don't ignore it, ask a question.
- 04-03-2012, 06:45 PM #5
Member
- Join Date
- Jan 2012
- Location
- Minnesota
- Posts
- 4
- Rep Power
- 0
Re: Arraylist of arraylists
Yes it is possible. An instance of the ArrayList class is declared, ArrayList<datatype> myList.
So you just need to make the an ArrayList of the type you want, i.e. if you wanted strings...
ArrayList<ArrayList<String>> list = new ArrayList<ArrayList<String>>();
-
Re: Arraylist of arraylists
Nothing "advanced" about this question. Moving from Advanced Java to the New to Java forum.
Similar Threads
-
Arraylists
By talia in forum New To JavaReplies: 5Last Post: 01-30-2012, 07:44 PM -
ArrayList copy some of the element from one arraylist tnto another arraylist
By ralf in forum New To JavaReplies: 12Last Post: 07-07-2011, 09:49 PM -
ArrayList of ArrayLists
By Dipke in forum New To JavaReplies: 4Last Post: 12-29-2010, 09:56 AM -
ArrayLists
By Freakzoyd in forum New To JavaReplies: 4Last Post: 11-12-2010, 05:27 AM -
ArrayList of ArrayLists
By coolnfunky_raj in forum New To JavaReplies: 10Last Post: 07-03-2008, 11:07 AM
Bookmarks