Advertisement
Guest User

Untitled

a guest
May 30th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.53 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class collectionExample {
  4.     public static void main(String[] args) {
  5.         ArrayList ListArr = new ArrayList();
  6.         LinkedList ListLinked = new LinkedList();
  7.         Vector ListVector = new Vector();
  8.         Stack ListStack = new Stack();
  9.        
  10.         ListArr.add(new String("A"));
  11.         System.out.println("ListArr(0) : " + ListArr.get(0));
  12.         ListLinked.add(new String("LA"));
  13.         System.out.println("ListLinked(0) : " + ListLinked.get(0));
  14.         ListVector.add(new String("V"));
  15.         System.out.println("ListLinked(0) : " + ListArr.get(0));
  16.         ListStack.push(new String("1"));
  17.         ListStack.push(new String("2"));
  18.         System.out.println("ListStack(0) : " + ListStack.pop());
  19.        
  20.         HashSet SetHashSet = new HashSet();
  21.         SetHashSet.add(new String("가"));
  22.         SetHashSet.add(new String("나"));
  23.         SetHashSet.add(new String("다"));
  24.         System.out.println("SetHashSet(0) : " + SetHashSet);
  25.         LinkedHashSet SetLinkedHashSet = new LinkedHashSet();
  26.         SetLinkedHashSet.add(new String("가"));
  27.         SetLinkedHashSet.add(new String("나"));
  28.         SetLinkedHashSet.add(new String("다"));
  29.         System.out.println("SetLinkedHashSet(0) : " + SetLinkedHashSet);
  30.         TreeSet SetTreeSet = new TreeSet();
  31.         SetTreeSet.add(new String("3"));
  32.         SetTreeSet.add(new String("1"));
  33.         SetTreeSet.add(new String("2"));
  34.         System.out.println("SetLinkedHashSet(0) : " + SetTreeSet);
  35.        
  36.         Queue Que = new LinkedList();
  37.         Que.add(new String("1"));
  38.         Que.add(new String("2"));
  39.         System.out.println("Que(0) : " + Que.poll());
  40.         Deque DeQue = new LinkedList();
  41.         DeQue.add(new String("1"));
  42.         DeQue.add(new String("2"));
  43.         System.out.println("DeQue(0) : " + DeQue.pollFirst());
  44.         System.out.println("DeQue(0) : " + DeQue.pollLast());
  45.        
  46.         HashMap MapHashMap = new HashMap();
  47.         MapHashMap.put(new String("국어"), new String("10"));
  48.         MapHashMap.put(new String("수학"), new String("20"));
  49.         MapHashMap.put(new String("영어"), new String("30"));
  50.         System.out.println("MapHashMap(0) : " + MapHashMap);
  51.         LinkedHashMap MapLinkedHashMap = new LinkedHashMap();
  52.         MapLinkedHashMap.put(new String("국어"), new String("10"));
  53.         MapLinkedHashMap.put(new String("수학"), new String("20"));
  54.         MapLinkedHashMap.put(new String("영어"), new String("30"));
  55.         System.out.println("MapLinkedHashMap(0) : " + MapLinkedHashMap);
  56.         TreeMap MapTreeMap = new TreeMap();
  57.         MapTreeMap.put(new String("영어"), new String("30"));
  58.         MapTreeMap.put(new String("국어"), new String("10"));
  59.         MapTreeMap.put(new String("수학"), new String("20"));
  60.         System.out.println("MapTreeMap(0) : " + MapTreeMap);
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement