Tuesday, 26 February 2013

Multiple ArrayList in Java

Like Multiple array also we can create and use multiple arraylist.

Declaration of Multiple ArrayList in JAVA.

ArrayList<integer> sets[];

initialization of Multiple ArrayList in JAVA.

sets = new ArrayList[5];

Sample program using Multiple ArrayList in JAVA.

public class A {
static ArrayList<integer> numbers[];

public static void main(String[] args) throws ParseException {
numbers= new ArrayList[5];
numbers[0] = new ArrayList<integer>();
// extending your code in order to use more than one value of the List array
numbers[1] = new ArrayList<integer>();
// if you want to get the values of first array.
for(int i = 0;i&ltnumbers[1].size();i++)
// if you want to get the values of whole arraylist.
for(int j = 0; j&ltsets.length;j++)
for(int i = 0;i&ltnumbers[j].size();i++)