Collections and Generics Flashcards
Enumerate all the Collections
- List
- Set
- Queue
- Map
Common collection method looks at how many elements are in the Collection
Collection.isEmpty(), Collection.size()
Common collection method, provides an easy way to discard all elements of the Collection.
Collection.clear()
Common collection method, checks if certain value is in the Collection.
Collection.contains()
List implementations
- Arraylist
- LInkedLIsts
- Vector
- ArrayDeque
List method, add elements to end
void add(E element)
List method, Adds element at index and moves the rest toward the end
void add(int index, E element)
List method, Returns element at index
E get(int index)
List method, Returns first matching index or -1 if not found
int indexOf(Object o)
List method, Returns last matching index or -1 if not found
int lastIndexOf(Object o)
List method, Removes element at index and moves the rest toward the front
void remove(int index)
List method, E set(int index, E e) Replaces element at index and returns original
E set(int index, E e)
Set Interface Implementations
HashSet
TreeSet
Navigable Set Interface, Returns greatest element that is < e, or null if no such element
E lower(E e)
Navigable Set Interface, Returns greatest element that is <= e, or null if no such element
E floor(E e)
Navigable Set Interface, Returns smallest element that is >= e, or null if no such element
E ceiling(E e)