Wednesday, 14 September 2016

Java Collections

import java.util.*;



public class CollectionsDemo {


public static void main(String args[])
{

List a= new ArrayList();
a.add("sri");
a.add("sahi");
a.add("teju");
System.out.print("Array : ");
System.out.print("\t"+a);



List l=new LinkedList();
l.add("nokia");
l.add("apple");
l.add("samsung");
System.out.println();
System.out.print("Linked list: ");
System.out.print("\t"+l);

Set s=new HashSet();
s.add("banana");
s.add("orange");
s.add("lemon");
System.out.println();
System.out.print("Set: ");
System.out.print("\t"+s);


Map m=new HashMap();
m.put("java", 1);
m.put("ruby",5);
m.put("html", 9);
System.out.println();
System.out.print("Map: ");
System.out.print("\t"+m);


}

}


==================================================================

No comments:

Post a Comment