[Java collections] Overview comparison of Java framework and arrays and the APIs involved

One: Overview of the Java framework

1.1 Overview of the Java Collections Framework 

On the one hand, object-oriented languages ​​embody things in the form of objects. In order to facilitate the operation of multiple objects, objects must be stored. On the other hand, there are some disadvantages in using Array to store objects , and Java collections are like a kind of container, which can dynamically put references of multiple objects into the container.

Features of arrays in memory storage:

   > After the array is initialized, the length is determined.

   >The type of array declaration determines the type of element initialization

Disadvantages of arrays in storing data:

   >After the array is initialized, the length is immutable, which is not easy to expand

   > There are few properties and methods provided in the array, which is not convenient for adding, deleting, inserting and other operations, and the efficiency is not high. At the same time, the number of storage elements cannot be directly obtained

   >The data stored in the array is ordered and repeatable. ---->The feature of storing data is single

The Java collection class can be used to store multiple objects of varying quantities , and can also be used to save associative arrays with mapping relationships

 Collection usage scenarios

 

Two: APIs involved in the collection framework

Java collections can be divided into two systems: Collection and Map

Collection interface : a single column of data that defines a collection of methods for accessing a set of objects

                     >List : an ordered and repeatable collection of elements

                     >Set : an unordered, non-repeatable collection of elements

Map interface : double-column data, saving a collection of " key-value pairs"

 Collection interface inheritance tree

The collection API provided by the JDK is located in the java.util package 

Map interface inheritance tree 

 

 thanks for watching! ! !

Guess you like

Origin blog.csdn.net/qq_64976935/article/details/129637083