Java Interview Basics------"list, Set, map similarities and differences in Java

Source: Internet
Author: User

Reference Address: http://blog.csdn.net/speedme/article/details/22398395

A few words like, copy down:

    1. There was no collection on Earth (only the array reference C language) but someone wanted it, so there was a collection
    2. Some people want an array that can be automatically expanded, so there's a list
    3. Some people want to have no duplicate arrays, so there's set
    4. Some people want to have automatic sorting of the number of groups, so with treeset,treelist,tree**

Same point:

1.list,set,map holds objects as object types.

2.Collection, List, Set, map are interfaces and cannot be instantiated.

Different points:

1.map is a key-value pair, andkey is always unique, and value allows repetition.

2. the number of elements stored in each location is different, collection type, each location has only one element. Map is a key-value pair

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

owning relationship:

Collection
--list: Elements are stored in a specific order. So the order taken out may be different from the order in which it is put.
--arraylist/linkedlist/vector
--set: cannot contain duplicate elements
--hashset/treeset
Map
--hashmap
--hashtable
--treemap

Java Interview Basics------"list, Set, map similarities and differences in Java

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.