The difference and use of Android Arraylist,linkedlist,hashset,vector,treeset

Source: Internet
Author: User

Tag:java    use     data    re   c   ar    

The collection of Java is just a few   general:list,set,map  (all interfaces are implemented by their subclasses)

Arraylist,linkedlist,vector all belong to List

List: The elements are ordered, and the elements can be repeated because each element has its own corner label (index)
  |-- arraylist: The underlying data structure is an array structure, characterized by: query fast, add   Delete   A little bit slower, the thread is out of sync

  |-- linkedlist: The underlying use of the linked list data structure, characterized by:   Delete quickly, query slow.

  |--vector: The underlying is the array data structure, thread synchronization, is replaced by the ArrayList, now use only his enumeration.


Set: The element is unordered and cannot be duplicated (the order in which it is stored and fetched does not necessarily coincide), the thread is out of sync.

  |--hashset: The underlying is a hash table data structure. Determines the uniqueness of an element according to the hashcode and equals methods

  |--treeset: You can sort the elements in the set collection (naturally sequential), and the underlying data structure is a two-fork tree, You can also write a class to implement the comparable  or  Comparator  interface, define your own comparator, and pass it as a parameter to the TreeSet constructor.

Map: This collection is a store of key-value pairs, one to the other, and to ensure that the key uniqueness (01, Zhang San) is printed out in the form of   01= Zhang San
   |-- HashTable: The underlying is a hash table data structure that cannot be stored in a null key and a null value, which is synchronous and less efficient. Appears in JDK1.0

   |--hashmap: The underlying is a hash table data structure that can be stored in NULL keys and null values, threads are out of sync, efficient, instead of Hashtable, appearing in jdk  1.2

   |--treemap: The underlying is a two-fork tree data structure, threads are out of sync, and can be used to sort keys in a map collection

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.