Term
|
Definition
The root interface in the collection hierarchy, it represents a group of objects. |
|
|
Term
|
Definition
It is an ordered collection (a sequence). The user has precise control over where each element is inserted. |
|
|
Term
|
Definition
A collection that contains no duplicate elements. |
|
|
Term
|
Definition
An object that maps keys to values. It cannot contain duplicate keys, and each key can map to at most one value. |
|
|
Term
What is the difference between a HashMap and HashTable? |
|
Definition
HashTable is synchronized and HashMap is not. |
|
|
Term
|
Definition
Resizable-array implementation of the List interface. It is not synchronized. |
|
|
Term
|
Definition
It implements a growable array of objects. It can grow and shrink as needed to accomodate the adding and removing items after the Vector has been implemented. |
|
|
Term
Which collection does not allow duplicates? |
|
Definition
|
|
Term
What is the difference between Vector and ArrayList? |
|
Definition
Vectors are synchronized, ArrayLists are not. |
|
|
Term
What is the advantage of an ArrayList and a HashTable? |
|
Definition
- ArrayList is an array, except it dynamically expands and contracts when elements are added/removed.
- HashTable is good when you want to lookup objects indexed by a 'key' value. |
|
|
Term
How would you code a For loop to read through a HashMap? |
|
Definition
You would use a ForEach loop, with the first param being the key, and the second being the obj's keySet().
example:
for(String key : temp.keySet()) { } |
|
|
Term
What is the difference between HashTable, HashSet, and HashMap? |
|
Definition
- HashTable maps keys to values, and any non-null obj can be a key or value.
- HashMap is like HashTable, but is unsynchronized and permits nulls.
- HashSet implements the Set interface, backed by a HashTable. |
|
|
Term
|
Definition
It means that some function or algorithm is used to map object data to some representative integer value. It helps narrows a search. |
|
|
Term
What are the two kinds of Maps that Java has? |
|
Definition
|
|
Term
|
Definition
Implements the Map interface, it is roughly the same as Hashtable except that it is unsynchronized and permits nulls.
HashMap<K,V> |
|
|
Term
|
Definition
Maps keys to values, does not permit nulls.
Hashtable<K,V> |
|
|
Term
|
Definition
Implements the Set interface, there are no guarentees to the iteration order, nor does it promise consistency of the order over time. Permits null elements.
HashSet<E> |
|
|
Term
|
Definition
Implements the Map interface, it sorts according to the natural ordering of its keys, or by a comparator provided at creation time.
TreeMap<K,V> |
|
|
Term
How is a LinkedList different from a ArrayList? |
|
Definition
- LinkedList: each element is linked to its previous element and next element.
- ArrayList: is an array-like list. |
|
|
Term
|
Definition
Implements the List interface, each element is linked to the previous and next element making it easier to delete or insert in the middle of the list. |
|
|