ArrayList program TBD

public class Collection_Demo {

public class Collection_Demo
 {
public static void main(String[] args)
 {
    // TODO Auto-generated method stub
   Collection_Demo cd = new Collection_Demo();
   cd.arraylist();
}

private void arraylist() {
    // TODO Auto-generated method stub
    ArrayList al = new ArrayList();
    al.add("shirt");
    al.add("pant");
    al.add(25);
    al.add(true);
    al.add('a');
    System.out.println(al);
    ArrayList al2 = new ArrayList();
    al2.add(al);

    System.out.println(al2);
    al2.add(0, 30);
    al2.add(1, "red pant");
    System.out.println(al2);

}
}
output:
[shirt, pant, 25, true, a]
[[shirt, pant, 25, true, a]]
[30, red pant, [shirt, pant, 25, true, a]]

Leave a comment

Design a site like this with WordPress.com
Get started