Java Collection Framework
Collection Frame :
① the so-called Framework is a collection of class libraries. A set framework is a unified schema used to represent and manipulate a collection, which contains the interfaces and classes that implement the collection;
The different collection classes in the ② collection framework have their own different data structures, so we should choose different collection classes according to the performance requirements of the application.
The ③ collection class is stored in the Java.util package, and the program will use the collection class and the related interface in a large number of programming.
A) iterable: iterator interface;
b) Collection: Class set interface;
c) List: Lists interface;
d) Set: Data set interface;
e) Queue: queues;
f) Map: Key-value pair combination mapping table;
iterable Interface :
① implements this interface to allow an object to be the target of a "foreach" statement, that is, the collection object allows iterations;
② class set interface collection is a sub-interface of iterable, so all class set objects can iterate access, and mapping map does not work;
③ Method:
Iterator<t> Iterator ()
Function: Returns an iterator that iterates over a set of elements of type T;
An iterator is an object of a class that implements the Iterator/listiterator interface, and can access each element of the operation by traversing the set of classes;
Listiterator extends the parent interface iterator, allowing bidirectional traversal of the collection and the ability to modify and delete elements;
Collection Interface :
The class set collection interface defines the method:
①int size ()
②boolean IsEmpty ()
③booean contains (Object o)
④iterator<e> Iterator ()
⑤object[] ToArray ()
⑥boolean Add (e E)
⑦boolean Remove (Object o)
⑧void Clear ()
List, Set, Map
①list interface expands the collection, features: orderly and repeatable ;
②set interface expands the collection, features: unordered and non-repeatable ;
③ Mapping (map) is an object that stores keyword/value pairs. Given a keyword, you can query to get its value, and both the keyword and the value can be objects. The mapping is not a collection sub-interface. So it cannot use iterators to traverse;
Introduction to the collection framework