Java Several collection usage cases

Source: Internet
Author: User

The difference between Collection and collections.

Collections is a Java.util class that contains a variety of static methods related to collection operations.

Collection is a Java.util interface, which is the parent interface of various collection structures.

Does the List, Set, and map inherit from the collection interface? List,set is map is not

The difference between ArrayList and vectors. Normal work priority use ArrayList
I. Synchronization: vector is thread-safe, that is, synchronous, and ArrayList is a thread program is not secure, not synchronous
Two. Data growth: When growth is needed, vectors grow by default to the original, while ArrayList is half the original

The difference between HashMap and Hashtable. Normal work priority use HashMap
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. Synchronization: Hashtable is thread-safe, that is, synchronous, and HashMap is a thread program is not secure, not synchronous

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

Java Several collection usage cases

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.