The collection framework:
- Collection
- Set
- HashSet more info here
- List
- ArrayList more info here
- LinkedList more info here
- Map more info here
- HashMap
- TreeMap
- Set
The above are the most commonly used classes ( HashSet , ArrayList , LinkedList , HashMap and TreeMap)
Collection interfaces:
Interface | Description |
Collection | Defines the basic methods available for all collections. |
Set | Defines a type of collection in which no duplicate elements are allowed. |
List | Defines a type of collection that maintains the order in which elements were added to the list. |
Map | Defines a map, which is similar to a collection but holds one or more key-value pairs instead of simple elements. Each key-value pair consists of a key that is uniquely indentifies an entry and a value that provides data associated with the particular key. |
Common collection classes:
Class | Description |
ArrayList | Works much like an array, but can be easily expanded to accommodate new elements. Very efficient for accessing individual elements in random sequence, but inserting elements into the middle of the List can be inefficient. |
LinkedList | Similar to an ArrayList, but with more features. Less efficient than an array list for accessing elements randomly, but more efficient when inserting items into the middle of the list. |
HashSet | A collection that stores a Set of unique values based on a hash code. Duplicates are not allowed. Objects you add to a HashSet must implement a method called hashCode to generate a hash code for the object, which is used to ensure uniqueness. |
HashMap | Similar to a HashSet, but is based on the Map interface rather than the Set interface. As a result, a HashMap stores key-value pairs whose keys must be unique. |
TreeMap | Stores key-value pairs in a special arrangement called a tree. Entries in a TreeMap are automatically maintained in a key sequence. |