Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 21 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
21
Dung lượng
232 KB
Nội dung
JavaProgramming II CollectionsJavaProgramming II Contents Collections Framework Collections of Objects Iterable and Iterator Comparable and Comparator The Legacy Collection Types JavaProgramming II Collections Collections are holders that let you store and organize objects in useful ways for efficient access In the package java.util, there are interfaces and classes that provide a generic collection framework The Collections interfaces: Collection, Set, SortedSet, List, Queue, Map, SortedMap, Iterator, ListIterator, Iterable Some useful implementations of the interfaces: HashSet, TreeSet, ArrayList, LinkedList, HashMap, TreeMap, WeakHashMap Exception Convetions: UnsupportedOperationException ClassCastException IllegalArgumentException NoSuchElementException NullPointerException JavaProgramming II Type Trees for Collections Set SortedSet Iterable Iterator Collection ListIerator Queue EnumSet List ArrayList PriorityQueue HashSet LinkedList TreeSet LinkedHashSet Map EnumMap WeakHashMap SortedMap HashMap TreeMap LinkedHashMap JavaProgramming II The Collection Interface The Collection Interface The basis of much of the collection system is the Collection interface public boolean removeAll(Collection coll) public boolean retainAll(Collection coll) public void clear() Methods: public int size() public boolean isEmpty() public boolean contains(Object elem) public Iterator iterator() public Object[] toArray() public T[] toArray(T[] dest) public boolean add(E elem) public boolean remove(Object elem) public boolean containsAll(Collection coll) public boolean addAll(Collection