Collection Collection
Features: variable length, only reference types can be stored, and different types of elements may be stored
List
Features: The elements are ordered (in the same order as they are stored and taken out) and can be repeated
Data structure: The underlying data structure is an array, query fast, and delete slowly. Thread insecure, high efficiency
Data structure: The underlying data structure is linked list, query slow, delete quickly. Thread insecure, high efficiency
Data structure: The underlying data structure is an array, query fast, and delete slowly. Thread-safe, low-efficiency.
Set
Features: element unordered, unique
data structure: the underlying data structure is a hash table. The bottom of the hash table relies on two methods: Hashcode () and Equals ().
Order of judgment when storing data:
1. First determine if the object's Hashcode () is the same.
2. Yes: Continue with equals () to see if its return value is
True: The description element is duplicated and not added.
False: It is added directly to the collection.
No: It is added directly to the collection.
when you see the collection of hash structures, we may need to rewrite hashcode () and Equals (). and we don't have to write it ourselves, and we can generate it automatically.
A collection of basic Java knowledge