1. The origin of the collection:
We are learning object-oriented language, and object-oriented language is the description of things through objects, in order to facilitate the operation of multiple objects, we have to store these multiple objects. To store multiple objects, you cannot be a basic variable, but rather a variable of a container type, what are the container types in the knowledge we have learned? Arrays and StringBuffer. But what? The result of StringBuffer is a string that does not necessarily meet our requirements, so we can only select an array, which is an array of objects . And the object array does not adapt to the needs of change, because the length of the array is fixed , this time, in order to adapt to the needs of change,Java provides a collection of classes for us to use .
2. The difference between a set and an array
(1) Length difference:
Fixed length of array
Variable Set length
(2) Different contents:
Arrays store elements of the same type
Collections can store different types of elements
(3) The data type problem of the element:
Arrays can store basic data types, or they can store reference data types
Collection can only store reference types
3. Features of the collection class
A: The collection is used only for storing objects, the collection length is mutable, and the collection can store different types of objects.
A collection framework for the reinforcement of Java Fundamentals Note 01: The origin of the collection differs from the array