import java.util.*;
public class ArrayListExp
{
public static void main(String args[])
{
ArrayList <String> obj=new ArrayList <String>();
obj.add("Honey");
obj.add("Sukhvir");
obj.add("Monu");
obj.add("Inder");
obj.add("Sonu");
obj.add("Preet");
obj.add("Hi");
obj.add("xyz");
System.out.println("Array Elements are:"+obj);
obj.add(4,"Doraha");
obj.remove("Preet");
System.out.println("Now Array Elements are:"+obj);
obj.remove(6);
System.out.println("Now Array Elements are:"+obj);
obj.set(6,"TOM");
System.out.println("Now Array Elements are:"+obj);
int pos=obj.indexOf("TOM");
System.out.println("Index of TOM is:"+pos);
int NOI=obj.size();
System.out.println("No of Items:"+NOI);
System.out.println("SS in the array is present or not:"+obj.contains("SS"));
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.