20-03-25 ----------- Q)What are the steps to deal with collections in a Java application? Step 1:- create an appropriate collection class object (list based/set based/map based) Step 2:- Perform CRUD operations on the collection object. C:- storing user defined domain objects into the collection object R:- Retrieving user defined domain objects from the collection object U:- Updating the user defined domain objects of the collection D:- deleting the user defined domain objects from the collection. Q)What are the important methods of List interface? List based collection diagram 1)add(element) 2)add(index,element) 3)get(index) 4)set(index,newelement) 5)remove(index) 6)indexOf(element) 7)listIterator() Q)Example porgram on List interface methods. import java.util.*; class ListMethodsExample{ public static List getList(){ return new ArrayList(); }//user defined method public static void main(String[] args){ List list=getList();//factory method list.add(10);//added at the index 0 list.add(20);//added at the index 1 list.add(1,15); System.out.println(list); System.out.println(list.get(1));//15 list.set(1,18); System.out.println(list); System.out.println(list.remove(2)+" deleted from the collection"); System.out.println(list); System.out.println("18 is in the list at the index "+list.indexOf(18)); ListIterator li=list.listIterator(); while(li.hasNext()){ System.out.print(li.next()+"\t"); } System.out.println(); while(li.hasPrevious()){ System.out.print(li.previous()+"\t"); } } }