Java Collection Framework usage considerations (two, Map)

Source: Internet
Author: User

The common implementation classes for the map interface are:

1.HashMap

2.Hashtable

3.TreeMap

4.LinkedHashMap

Discussion 1: underlying mechanisms

HashMap and Hashtable based on array implementation, TREEMAP based on tree structure, the underlying storage structure is a typical linked list structure. Linkedhashmap inherits from HashMap, so it is also based on an array implementation.

Discussion 2: Inheritance relationships

HashMap and TreeMap inherit from the Abstractmap,hashtable inheritance from the Dictionary,linkedhashmap inheritance from HashMap.

Discussion 3: Synchronizing relationships

Hashtable are synchronized, and HashMap are not synchronized with TreeMap and Linkedhashmap, and can be converted to synchronous using the methods provided in collections.

Discussion 4: iterators

Iterators are fast failures (note: Refer to the first list in this series)

Discussion 5: Not modifiable

By using Collections.unmodifiablemap (map map) to convert

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.