Eg:
public static void
main(String[]args){
//creation of
Arraylist with string arguments
//adding elements to
Arraylist
ArrayList<String>
al=new ArrayList<String>();
al.add("India");
al.add("US");
//Displaying elements
of Arraylist
System.out.println(al);
//creation of
Arraylist 2 with string arguments
ArrayList<String>
al2=new ArrayList<String>();
//adding elements to
Arraylist 2
al2.add("Australia");
al2.add("Germany");
al2.add("Europe");
al.addAll(2,al2);
}
Output:[India,US,Australia,Germany,Europe]
0 comments:
Post a Comment