package collections;
import java.util.*;//library
public class Collections {
//Purpose:Create an ArrayList which stores strings
public static void main(String[] args) {
List<String> l = new ArrayList();
String first="Hello";
l.add(first);
l.add(" world");
l.add("JAVA");
l.set(2,"JAVA2");//set modifies a value of the list
Collections.sort(l);//sort the list
System.out.println(l);
System.out.println("Size of the list = " + l.size());
int i = l.indexOf(" world");//will return the position of <world>
System.out.println("String <world> is at " + i + " cell");
l.remove("JAVA2");//will remove the first appearence of <JAVA2>
l.clear();//removes all the elements of the list
if(l.isEmpty())
System.out.println("empty list");
System.out.println(l);
}
}