Home Tutorial Java Collections Arraylist Java arraylist of arraylist


Share on Google+Share on Google+
Java arraylist of arraylist
Posted on: October 23, 2009 at 12:00 AM
This section demonstrates how to make Java ArrayList of the ArrayList

  • Java arrayList can make the use of other arrayList. 
  • In one arrayList other arrayList can be added as the object 
  • It works as two dimension array.

Example of Java Arraylist of Arraylist
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class List1 {
    public static void main(String[] args) {
       ArrayList list=new ArrayList();
       ArrayList list1=new ArrayList();
       for(int x=0;x<=2;x++)

       ArrayList list2=new ArrayList();
       for(int x=0;x<=2;x++)

       ArrayList list3=new ArrayList();
       for(int x=0;x<=2;x++)

        for (int i = 0; i < list.size(); i++) {            
           for (int j = 0; j < (list.get(i)).size(); j++) {

[[14, 8, 7], [0, 7, 11], [14, 9, 14]]

14   8   7 
0    7   11 
14   9   14 

Related Tags for Java arraylist of arraylist:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 23, 2009

Recommend the tutorial

Advertisements Advertisements