120. Collection

1. What is a collection? Why use collections? What problem does the collection solve?

The Java collection class is stored in the java.util package, which is a Java container for storing objects. Like arrays, collections are structures for storing multiple data.

Are arrays not very useful? Why use collections? ?

The length of the array is fixed and can only store the same type of data!!!

What if you want to change the length type as the code becomes more complex? !

Operations such as adding, deleting, and inserting data to an array are not easy to use and not efficient

In the past, the actual number of elements in the array could not be realized.

At this time a collection

1 The collection can only store objects, references to objects, and can store different types, unlimited number

2 Arrays can only be ordered and elements can be repeated, right! Collection is all right!

HashSet is disordered and not repeatable

Guess you like

Origin blog.csdn.net/weixin_43206161/article/details/112324669