Introduction to the collection framework

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.