1. List collection: (ordered, elements can be repeated)
1. ArrayList collection:
1) The underlying data structure is an array, which is fast to search but slow to add and delete.
2) Thread is not safe and efficient
2. Vector collection:
1) The underlying data structure is an array, which is fast to query and slow to add and delete.
2) Thread safety, low efficiency
3. LinkedList collection:
1) The underlying data structure is a linked list, which is slow to query and fast to add and delete
2) Thread unsafe, high efficiency
2. Set collection (elements cannot be repeated, elements are unique)
1. Hashset collection :
1) The underlying data structure is a hash table, and the hash table relies on two methods, hascode () and equals () method
2) The execution order of the two methods:
First determine whether the hascode() values are the same
Yes: continue to execute the equals() method and see its return value
is true: it means that the elements are repeated, do not add
is false: add the element directly
No: add it directly to the collection
2, Treeset collection:
1) Bottom layer The data structure is a binary tree
Recommended tutorial:Java tutorial
The above is the detailed content of What are collections in java. For more information, please follow other related articles on the PHP Chinese website!