Java Collections Framework Flashcards
What are the 2 interfaces in the Java Collections Framework?
Map
Collection
What is the benefit of collections being generic?
Polymorphism.
Bugs caught at compile time.
What are the 4 structures in that inherit Collection?
Set, List, Queue, Dequeue
Define each of the 3 set implementations…
HashSet : No order; fastest.
TreeSet : Order based on value; Slower than hash set.
LinkedHashSet : Order based on input.
Are List structures ordered?
Yes.
What are the 2 concrete implementations of List?
ArrayList
LinkedList
Define the Queue structure…
A collection of data stored for processing. FIFO processing.
What are the 4 main methods for Queue?
add : Adds element to queue if possible, throws exception if not.
offer : Adds element to queue if possible. Returns false if not.
remote : Removes and returns the head of the queue, throws NoSuchElementException if not.
poll : Remove and returns head of queue, returns null if not.
Define a Dequeue…
A double ended queue that can be inserted and deleted from either end.
What are the 3 types of operation on Dequeue?
Insert, Remove, Examin.
Define the Map interface…
No a direct collection, rather a collection of references that map to values.
Define the 3 types of map…
HashMap : Fastest, order irrelevant.
TreeMap : Order guaranteed based on value.
LinkedHashMap : Order based on order of insertion.