Summary of the Java Collection framework

Source: Internet
Author: User

One: Set frame
A collection framework is a uniform standard architecture that is defined for representing and manipulating collections.
Any set frame contains three chunks of content: external interfaces, interface implementations, and algorithms for set operations.

interface: The abstract data type that represents the collection. Collection top-level interface.
implementation: That is, the concrete implementation of the interface in the collection framework. Common ArrayList, HashMapalgorithm: An object that implements an interface in a set framework to perform a useful calculation, such as finding, sorting, and so on.
II: What the Java Collection Framework contains
the main common
interface Collection Map
List Set
Specific class ArrayList linkedlist HashSet TreeSet HashMap Tr Eemap
The algorithm collections collections is a Java.util class that contains a variety of static methods related to collection operations. Used to sort, query, modify, etc. on a collection element

List sorted by index, objects that can be duplicated
Set has no order, cannot duplicate object
Map stores a pair of key-value objects, the key object cannot be duplicated, and the value object can be repeated
Three: The implementation class of the list interface
ArrayList is an array of ways to implement the query
 
LinkedList the use of linked list storage for frequent addition or deletion of elements
methods in the list interface
void Add (int index,object o) Inserts an object at the position indicated by the list
Object get (int index) returns the list of objects specified by the collection
Object Set (int index,object o) replaces the specified objects in the list with the specified object
object Remove (int index) deletes the objects at the specified position in the list
Basic methods of LinkedList class
void AddFirst (object o) adds an object at the beginning of the list
void AddLast (object o) adds an object at the end of the list
Object GetFirst () returns the first element in a linked list
Object GetLast () returns the last element in the linked list
Object Removefirst () deletes the first element in a linked list
Object removelast () deletes the last element in a linked list
Four: Implementation class for set interface
Haseset: Storing elements as a hash table, inserting deletes quickly
V: Map interface
The map contains two objects, one called key (key), one called value, which is a one by one correspondence in the map, the key object cannot be duplicated, and the value object can be repeated
basic methods of map classes
get (Object key) returns the value associated with the specified key
put (Object key,object value) adds a key-value pair to the map
Remove (Object key) removes the key-value pair that contains the specified key from the map
Clear () Delete all elements in the map
VI: Iterator iterator (interface) an interface for traversal
method of Iterator interface
Boolean Hasnext () to determine if another accessible element exists
Object Next () returns the next element to be accessed
Remove () removes the last element returned by iterator
eg: how do I traverse every element in the collection? Regardless of the actual type of collection, it supports a iterator () method that returns an iteration that uses the iteration to access each element of the collection one at a time. Typical usage is as follows:Iterator it = Collection.iterator ();//Get an iteration
While (It.hasnext ()) {Object obj = It.next ();//Get Next element
     }  the two interfaces that are derived from the collection interface are list and set.
Seven: Generics
list (list<e>)
list (list<e>)
Mapping (map<k,v>)

Summary of the Java 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.