What is the difference between arraylist and vector? What is the difference between hashmap and hashtable?

Source: Internet
Author: User

What is the difference between arraylist and vector? What is the difference between hashmap and hashtable?

Arraylist and vector are mainly used in two aspects.
1. Synchronization: the vector is thread-safe, that is, synchronous, And the arraylist is a line.ProgramNot secure, not synchronous
2. Data growth: When we need to increase, the vector grows to the original training by default, while the arraylist is half of the original growth.
Hashmap and hashtable are mainly used in three aspects.
I. Historical Reasons: hashtable is based on the obsolete dictionary class, And hashmap is an implementation of the map interface introduced by Java 1.2.
2. Synchronization: hashtable is thread-safe, that is, synchronous, while hashmap is not secure or synchronous.
3. Value: Only hashmap allows you to use a null value as the key or value of a table entry.

Collection
Shortlist
│ Invalid parameter list
│ ├ Arraylist
│ Vector
│ Elastic Stack
Sorted set
Map
├ Hashtable
├ Hashmap
└ Weakhashmap
Collection is the most basic collection interface. A collection represents a group of objects, that is, elements of the collection)
Map provides key-to-value ing

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.