Set Features:
1. Element types can vary.
2. The set length is variable.
3. Space is not fixed.
In Java, some data structures and algorithms are encapsulated as a collection, which is also an object for storing, retrieving, manipulating, and transmitting objects.
JFC (Java Collections Framework) collection framework, which provides interfaces and classes for managing collections
The collection framework consists of three elements: interface, implementation class, algorithm
Interface: Collection is the parent interface for list and set. The list is characterized by: linear, elements can be repeated. Set is characterized by: elements cannot be duplicated.
Map collection: An element contains two objects (key objects and value objects), and keys cannot be duplicated.
The difference between a collection and an array:
1. Only references to objects can be stored in the collection, either as primitive types or as reference types.
2. The length of the collection can vary with the number of elements, and when the array is created, the length cannot change.
3. The collection algorithm is rich, can save a lot of developers coding, but the array algorithm is limited.
How to traverse:
1.for loop traversal, only for the list collection.
2. Iterator method, get the algorithm and interface of the iterator. Iterator
3.for each way
Iterator method to get the iterator algorithm interface
Itertor<student> It=stu.itertor ();
while (It.hasnext) {
Student S=is. Next ();
}
java--Collection