- Various implementations exist based on the
List,Map, andSetinterfaces Reasons for use- Because
standardized classesare provided for handling large amounts of data, you can use them conveniently without directly implementing DataStructures - Unlike arrays,
you don't need to pre-define the space for storing objects, so thenumber of objects can be determined dynamicallybased on the situation- This also improves the spatial efficiency of the program
- Because
- The
Listinterface can be directly defined and used by the user through@Override, and the representative implementation isArrayList.- This is an improvement of the existing
Vector
- This is an improvement of the existing
LinkedList- A data structure that stores data in a manner where each node has data and a pointer, connected in a single line
- Nodes containing data are connected, and the node's pointer is responsible for the connection to the next or previous node
Advantages- Adding/removing data at the middle of the lined-up nodes is possible in
O(1)time
- Adding/removing data at the middle of the lined-up nodes is possible in
Disadvantages- Unlike arrays or tree structures, searching for data at a specific position takes
O(n)time
- Unlike arrays or tree structures, searching for data at a specific position takes
- The representative implementation is
HashMap - It has a
key-valuestructure, and the specific details about Map are consistent with thehashtablein the DataStructure section Duplicate values are not storedbased on the key, andorder is not guaranteed- To guarantee order for keys, use
LinkedHashMap
- The representative implementation is
HashSet. - Duplicate values for
valueare not stored - In fact, the Set data structure is simply a data structure where the value is used as the key, replacing the key in the Map's key-value structure
- Likewise, order is not guaranteed, and
LinkedHashSetis used to guarantee order