Java Collection Framework

Source: Internet
Author: User

1.Collection interface

<<interface>> java.util.collection<e>

    • Add (O:e): Boolean adds a new element to the collection O
    • AddAll (c:collection<? extends E>): Boolean adds all elements from collection C to this collection
    • Clear (): void deletes all elements in the collection
    • Contains (O:object): Boolean returns True if the collection contains elements O
    • Containsall (C:collection <?>): Boolean returns True if the collection contains all the elements in C
    • Equals (O:object): Boolean returns True if the collection equals another collection O
    • Hashcode (): int returns the hash code for the collection
    • IsEmpty (): Boolean returns True if the collection does not contain any elements
    • Iterator (): Iterator<e> returns the iterator used for the elements in the collection
    • Remove (O:object): Boolean removes an element from the collection O
    • RemoveAll (c:collection<?>): Boolean removes all elements from the collection in C
    • Retainall (c:collection<?>): Boolean retains C and elements of the collection
    • Size (): Int returns the number of elements in the collection
    • ToArray (): object[] Returns an array of elements of the collection Object

<<interface>> java.util.iterator<e>

    • Hasnext (): Boolean returns True if the iterator has more elements to traverse
    • Next (): E returns the next element from the iterator
    • Remove (): void Delete the last element obtained using the next method

2. java.util.hashset<e>

    • Hash ()
    • HashSet (c:collection<? extends e>)
    • HashSet (Initialcapacity:int)
    • HashSet (Initialcapacity:int, Loadfactor:float)

Java.util.linkedhashset<e>

    • Linkedhashset ()
    • Linkedhashset (c:collection<? extends e>)
    • Linkedhashset (Initialcapacity:int)
    • Linkedhashset (Initialcapacity:int, Loadfactor:float)

3. List

    • Add (Index:int, Element:e): Boolean adds a new element at the specified subscript
    • AddAll (Index:int, c:collection<? extends e>) Add all the elements in C at the specified subscript
    • Get (Index:int): E returns the element at the specified subscript in the list
    • IndexOf (element:object): int returns the subscript of the first matched element
    • LastIndexOf (element:object): int returns the subscript of the last matched element
    • Listiterator (): Listiterator<e> Returns the elements of this list all the list iterators
    • Listiterator (startindex:int): Listiterator<e> returns all iterators for elements starting from StartIndex
    • Remove (index:int): E deletes the element at the specified subscript
    • Set (Index:int, element:e): E sets the element at the specified subscript
    • Sublist (Fromindex:int, toindex:int): List<e> Returns a sub-list from FromIndex to ToIndex-1

<<interface>> java.util.listinterator<e> expands the iterator interface, increasing the bidirectional traversal capability of the linear table

    • Add (o:e): Void adds the specified object
    • Hasprevious (): Boolean returns True if the list iterator has more elements in the back-pass-through.
    • Nextindex (): Int returns the subscript of the next element
    • Previous (): E returns the previous element in this list iterator
    • Previousindex (): Int returns the subscript of the previous element
    • Set (O:E): Void replaces the last element returned by the previous method or the next method using the specified element

Java.util.arraylist<e>

    • ArrayList () Creates an empty list with the default initial capacity
    • ArrayList (c:collection<? extends e>) Create an array list from an existing collection
    • ArrayList (Initialcapacity:int) creates an empty list with the specified initial capacity
    • TrimToSize (): Void reduces the capacity of this ArrayList instance to the current size of this list

Java.util.linkedlist<e>

    • LinkedList () to create a default empty list
    • LinkedList (c:collection<? extends e>) Create a list from an existing collection
    • AddFirst (o:e): Void adds an object to this list header
    • AddLast (o:e): Void adds an object to the end of this list
    • GetFirst (): E returns the first element of this list
    • GetLast (): E returns the last element of the list
    • Removefirst (): E returns and Deletes the first element of this list
    • Removelast (): E returns and Deletes the last element of this list

4.java.util.queue<e>

    • Offer (Element:e): Boolean to insert an element into the queue
    • Poll (): E gets and deletes the queue header and returns null if the queue is empty
    • Remove (): E gets and deletes the queue header and throws an exception if the queue is empty
    • Peek (): E gets but does not delete the queue header and returns a null if the queue is empty
    • Element (): E gets but does not delete the queue header and throws an exception if the queue is empty

5.java.util.map<k, v>

    • Clear (): Void Delete all entries in the diagram
    • ContainsKey (Key:object): Boolean returns True if the figure contains an entry corresponding to the specified key value
    • Containsvalue (Value:object): Boolean returns True if the graph maps one or more key values to a specific value
    • EntrySet (): Set<map.entry<k, V>> returns a rule set containing the entries in the diagram
    • Get (Key:object): V returns the value corresponding to the specified entry in the graph
    • IsEmpty (): Boolean returns True if the graph does not contain any entries
    • KeySet (): set<k> Returns a rule set containing the key values in the graph
    • Put (Key:k, value:v): V put a map in the diagram
    • Putall (m:map<? extends K,? extends v>): Void adds all entries from M to the diagram
    • Remove (key:object): V deletes entries for the specified key value
    • Size (): Int returns the number of entries in the graph
    • VALUES (): Collection<v> Returns a collection containing the values in the graph

Java.util.hashmap<k,v>

    • HashMap ()
    • HashMap (Initialcapacity:int, Loadfactor:float)
    • HashMap (m:map<? extends K,? extends V>)

Java.util.linkedhashmap<k,v>

    • Linkedhashmap ()
    • Linkedhashmap (m:map<? extends K,? extends V>)
    • Linkedhashmap (Initialcapacity:int, Loadfactor:float, Accessorder:boolean)

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.