Interface for collection interface single-column collection
List has indexed order
Set no index unordered
Abstractcollection is an abstract parent class that implements the collection interface
collection<> C = new arraylist<> ();
Polymorphism can only be used by the parent class method, not the subclass-specific method
A general method of collection
Add added ()
Delete Remove ()
Empty collection Clear ()
Determines whether an element is empty IsEmpty
Determine if an element exists contains ()
The length of the collection size ()
Enhanced for foreach Traversal container has no index
for (data type TEMP variable: The collection that needs to be traversed) {
You can print variables directly
}
Iterator Iterator
To create an iterator object for a collection
Use Hasnext to determine if there is a next element
Next gets the next element
Concurrency modification Exceptions
In the iterative process, the collection can not add elements to itself or delete elements, but can use iterators to add or change
Iterate and iterate distinguish iterative emphasis on repetition of actions
Shuffle the method Collections.shuffle (pass a set);
Common method for collection interface collection foreach Iterator iterator