On the difference between ArrayList and Vector in Java and the difference between HashMap and Hashtable _java

Source: Internet
Author: User

ArrayList and Vector are mainly from two aspects.
I. Synchronicity: vectors are thread-safe, that is, synchronous, while ArrayList is not secure, not synchronized.

Two. Data growth: When growth is needed, the vector defaults to the original one, while ArrayList is half the original.

On HashMap and Hashtable mainly from three aspects.
I. Historical reasons: Hashtable is based on the old dictionary class, HashMap is an implementation of the map interface introduced by Java 1.2

Two. Synchronicity: Hashtable is thread-safe, that is, synchronous, and HashMap is not secure, not synchronized.

Three. Value: Only HashMap can let you use NULL as the key or value of a table entry

Collection
├list
│├linkedlist
│├arraylist
│└vector
│└stack
└set
Map
├hashtable
├hashmap
└weakhashmap

Collection is the most basic set interface, and a collection represents a set of object, that is, the collection element (Elements)
Map provides a mapping of key to value

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.