The role of the collection framework
In actual development, we often perform unified management operations on a set of the same type of data. So far, we can use arrays, linked list structures, and binary tree structures to achieve this.
The biggest problem with arrays is that the number of elements in the array is fixed. To implement a dynamic array, comparison is still troublesome. It is even more inconvenient to implement a linked list or binary tree structure to manage objects by yourself.
After JDK1.2, JAVA fully provides the concept of class collections and encapsulates a set of powerful and very convenient collection framework APIs, which greatly improves our efficiency in development.
Collections are divided into three major interfaces
Collection (collection), Map (mapping), Iterator (iteration, convenience)
The interfaces and classes of the collection framework are in the Java.util package
Collection framework structure diagram
Collection interface
1. The root interface in the Collection hierarchy. Collection represents a set of objects, which are also called elements of the collection. Some collections are ordered, while others are unordered,
Some collections allow duplicate elements, while others do not. The JDK does not provide any direct implementation of this interface: it provides implementations of more specific sub-interfaces such as Set and List.
2. Definition of interface
public interface Collection
extends Iterable
3.Collection provides an interface for some common operations on collections, including
insert add()
Delete remove()
Judge whether an element is its member contains()
Traverse iterator()