First, set concept
I believe we all know that Java is an object-oriented programming language, and the embodiment of things are in the form of objects, so in order to facilitate the operation of multiple objects, the object is stored for storage, collection is the most common way to store objects, we can think of the set as a container.
Similarly, an array is also a container, so what is the difference between a collection and it?
1. Arrays can also store objects, but the length is fixed, and the set length is variable.
2. The base data type data can be stored in an array, and the collection can store only objects.
3. The basic data type data or objects stored in the array are of the same type, and the collection can store different types of objects.
Therefore, a collection class is required when you do not know the number of data to be stored beforehand, or if you need a method that is more flexible than the array subscript access mechanism .
Java Fundamentals: Collection Summary