Container
1. Container: An instance of a series of classes provided by the Java API for storing objects in a program. (The object is stored, not the underlying data type: Because the data on the stack can be emptied at any time)
2. The collection interface defines a method for saving a set of objects, and its sub-interface set and list define the storage mode separately: A, set class and its subclasses are stored, the storage objects are unordered and non-repeatable; B, the list class and its subclasses are stored, The stored objects are ordered and repeatable. (The repetition here is between two objects equals ())
3. The map interface defines a method for storing key (key)-value mapping pairs.
4, the container class object when calling remove, contains and other methods, you need to compare the object is equal. This involves the Equals method and the Hashcode method of the object type, and for custom types, you need to override the Equals and Hashcode methods to implement custom object equality rules. (Note: Equal objects should have equal hash codes.) (the default method of equals in Java.lang.Object is to determine whether two objects are the same object.) )
5. Iterator interface: All containers that implement the collection interface have a iterator method for returning an object that implements the iterator interface. This object is called an iterator to facilitate the traversal of elements within a container. The iterator interface defines the following methods:
Boolean hasnext ();//Determine whether the right side of the cursor is an element
Object Next ()//returns the element to the right of the cursor and moves the cursor to the next position
Void remove ();//delete the element to the left of the cursor, which can only be executed once after the next execution
The iterator of the middle reaches the following chart:
Note: The Remove method of the Iterator object is the only safe way to remove an element during an iterative process.