1. What is a framework: a collection of class libraries
2. Collection framework: A unified architecture for representing and manipulating the interfaces and classes that implement a collection
3. Collection: Container for storing data
A collection framework consists of two parts: a part is an interface, and a part is a class
4. Why interfaces occur: Because many of the class functions in the collection framework are similar, "use interfaces to standardize classes"
Java SE contains a Java collection framework (JCF) consisting of a set of classes and interfaces, whose primary function is to organize and access stored data in a certain structure and in a specific way.
3 implementations of the set interface:
The HashSet object must implement the Hashcode method, Javaapi Most classes implement the Hashcode method.
Linkedhashset implements an extension to the HashSet, supports the ordering of elements within the ruleset, has no order in the HashSet, and in Linkedhashset, it can be extracted in the order in which the elements are inserted into the collection
TreeSet guarantees that the elements of the set are orderly, there are 2 ways to achieve comparability between objects: 1, objects added to TreeSet implement the comparable interface, 2, specify a comparer for the elements of the ruleset (Comparator)
How objects are stored:
1.Set (SET): Objects in an object container have no order and cannot be duplicated.
2.List (list): Objects in the object container are sorted by index and can be duplicated.
3.Map (map): An element in an object container contains a pair of "key Object-Value object" mappings where key objects cannot be duplicated and value objects can be duplicated.
The collection interface is the parent interface of the set interface and list, which defines a common method for the set type and the list type implementation class.
ArrayList: Realized by array, continuous space, high query efficiency.
LinkedList: Realized by the chain list, increase, delete, change the efficiency high.
Collections class and Arrays class:
Collections Class (Note not collection): Provides a number of static methods to manage collections, linear tables (most of which are to manipulate linear tables, such as for linear table copying, sorting, etc., see API)
Arrays class: Provides a variety of static methods for sorting, locating, comparing, and populating elements of an array.
General types of Use:
refers to using generics in the Java collection to specify the type of element to add:
hashmap<k,v> map = new hashmap<k,v> () where K,v is a two class type, indicating that only objects of the K,v type can be populated here
In addition, only objects can be added to the collection, and the basic data types are automatically transformed into corresponding wrapper classes.
Java--java Collection Frame