A collection of Java review and collation

Source: Internet
Author: User
Tags comparable set set

------<a href= "http://www.itheima.com" target= "blank" >java training, Android training, iOS training,. NET training </a>, looking forward to working with you
Communication! ------

A collection of Java review and collation:

Collection: The topmost interface in the collection, which provides a common approach to some set of operations
Add to:
Boolean Add (E E)
Boolean AddAll (collection<? extends e> c)
Delete:
void Clear ()
Boolean remove (Object o)
Boolean RemoveAll (collection<?> c)
Get:
Iterator<e> Iterator ()
int size ()
Judge:
Boolean contains (Object o)
Boolean containsall (collection<?> c)
Boolean IsEmpty ()

List: Elements are ordered and can be duplicated because the collection system has an index
--arraylist: The underlying data structure uses an array structure. Features: Fast query speed, but slightly slower to delete
--linkedlist: The underlying uses a linked list data structure. Features: Fast and easy to delete, query slightly slow
--vector: The underlying is the array structure, thread synchronization

Set: Elements are unordered, elements are not repeatable
--hashset: Underlying data structure, hash table
--linkedhashset
--treeset: Underlying data structure, binary tree

Map: Represents a mapping relationship, stored as a key-value pair, to guarantee the uniqueness of the key
--hashmap
--The implementation of MAP interface based on hash table. This implementation provides all the optional mapping operations and allows NULL values and NULL keys to be used. (in addition to not synchronizing and
In addition to allowing nulls, the HashMap class is roughly the same as Hashtable. This class does not guarantee the order of the mappings, especially because it does not guarantee that the order is constant.
--treemap
--it implements the implementation of the SortedMap interface based on the red-black tree. This class ensures that the mappings are sorted in ascending order of keywords, depending on the construction method used, can be
Can be sorted by the natural order of the class of the key (see comparable), or by the comparer provided when created
--hashtable
--This class implements a hash table that maps the keys to the corresponding values. Any non-null object can be used as a key or a value
Two ways to remove a map collection:
1,set<k> KeySet: Deposits all the keys in the map into the set set because the set has an iterator
So you can take the key out of an iterative way, and then get the corresponding value based on the Get method.

2,set<map.entry<k,v>> EntrySet: The mappings in the map collection are stored in the set set
And the data type of the relationship is: map.entry

The frame diagram is as follows:


Comparable interface:
This interface forces the overall ordering of the objects for each class that implements it. This sort is called a natural sort of class, class
The CompareTo method is referred to as its natural comparison method, in short, the interface is a natural order, the implementation of comparable can be based on natural
Sequential sorting

Collections class:
The arrays class is used to manipulate arrays, and its methods are all static.
The collections class is used to manipulate the collection, and its methods are all static.
Arrays can use the Sort method to sort the array.
Collections can also use the Sort method to sort the collection.

------<a href= "http://www.itheima.com" target= "blank" >java training, Android training, iOS training,. NET training </a>, looking forward to working with you
Communication! ------

A collection of Java review and collation

Related Article

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.