Java Collection notes 1
1. What is the origin of the collection?
We are learning Java-object-oriented-manipulating many objects--storing--containers (arrays and StringBuffer)--arrays whose lengths are fixed, so it is not suitable for changing requirements, and Java provides a collection for us to use.
2. What is the difference between a collection and an array?
A: Length Difference
Array pinning
Set Variable
B: Content Differences
An array can be a base type, or it can be a reference type
Collections can only be reference types
C: element content
Arrays can only store the same type
Collections can store different types (in fact, collections typically store the same type)
3. The inheritance architecture of the collection?
Because of the different requirements, Java provides different collection classes. The data structure of these multiple collection classes is different, but they are all to provide storage and traversal function, we take their generality upward extraction, and finally formed a collection of inheritance architecture diagram.
Collection
|--list
|--arraylist
|--vector
|--linkedlist
|--set
|--hashset
|--treeset
Java Collection 1