Collections Framework Beginners guide

  • View
    9.909

  • Download
    0

Embed Size (px)

DESCRIPTION

社内勉強会「Collections Frameworkビギナーズガイド」講義資料

Text of Collections Framework Beginners guide

  • 1. Collections FrameworkBeginners guideHASUNUMA KenjiVice president, GlassFish Users Group Japank.hasunuma@coppermine.jpTwitter: @btnrouge

2. Introduction 3. Collections Framework? java.util 4. Collection - Set - List - / Deque - Map - 5. Set List Deque MapHashHashSet -- -- HashMapTableResizable--ArrayListArrayDeque --ArrayBalancedTreeSet -- -- TreeMapTree Linked--LinkedList LinkedList -- ListHash Table LinkedLinked +-- --Linked List HashSet HashMap 6. Hash Table () ()Resizable Array () () Balanced Tree () () ()Linked List () ()1 7. How to select the type 8. 1. : String, Integer, BigDecimal, etc.2. : Set, List, Deque, Map3. 9. 1 : String1. String2. : Set3. : HashSetSet set = new HashSet(); 10. 2 : int1. Integer ()2. : List3. : ArrayListList list = new ArrayList(); 11. 3 : Integer1. Integer2. : List3. : LinkedListList list = new LinkedList(); 12. Basic operations 13. Collection boolean add(E e) void clear() boolean isEmpty() boolean remove(Object o) int size() T toArray(T[] a) 14. List boolean add(int index, E element) E get(int index) int indexOf(Object o) int lastIndexOf(Object o) int remove(int index) E set(int index, E element) 15. Deque() boolean add(E e) [exception] void oer(E e) E poll() E element() [exception] E peek() E remove() [exception] 16. Deque() void push(E e) E pop() E peek() 17. Map void clear() boolean containsKey(Object key) V get(Object key) V put(K key, V value) V remove(Object key) int size() 18. : Collections (List) (List) (List) (List) 19. Collection : forfor ( : or) ; Collection ListSetDeque 20. // Example #1:// print any elements in the List// to upper case every lines.List list = new ArrayList();...for (String s : list) {// show elements (to upper case)System.out.println(s.toUpperCase());} 21. // Example #2:// print any elements in the Set// to upper case every lines.Set set = new HashSet();...for (String s : set) {// show elements (as upper case)System.out.println(s.toUpperCase());} 22. Attentions 23. Collections Framework () : Collections Concurrency Utilities() 24. VectorHashtableCollections Framework: Vector List Hashtable Map null 25. Java() http://docs.oracle.com/javase/7/docs/technotes/ guides/collections/ Java11 Java4 Java SE 6 ISBN978-4-89471-714-5 26. Collections FrameworkBeginners guide HASUNUMA Kenji Vice president, GlassFish Users Group Japan k.hasunuma@coppermine.jp Twitter: @btnrouge