JAVA container
Collection
Collection is a linear container
List
1. There can be repeated elements inside the List
2, the internal elements are ordered
Types of | storage structure | thread safety |
---|---|---|
ArrayList | order | unsafe |
LinkedList | chain | unsafe |
Vector | order | Safety |
Set
1. There can be no duplicate elements inside the Set, and there can only be one null at most
. 2. The internal elements are unordered
Types of | storage structure | thread safety |
---|---|---|
HashSet | hash table | unsafe |
TreeSet | tree shape | unsafe |
Map
Map is a key-value pair container <key, value>
1, the value can be repeated, the key cannot be repeated,
2, there can be multiple values that are null, but only one key can be null
Types of | storage structure | thread safety |
---|---|---|
HashMap | hash table | unsafe |
TreeMap | tree shape | unsafe |
HashTable | hash table | Safety |
Ps: If there are other commonly used containers, please comment and add