Java Collection, Map Collection Summary

Source: Internet
Author: User

Summary of collection collection in 1.Java

Collection

|---List (stored in order, repeatable)

|---ArrayList

The underlying data structure is an array, query fast , and delete slowly.

Thread insecurity, high efficiency

|---Vector

The underlying data structure is an array, query fast, and delete slowly.

Thread-safe, low-efficiency.

|---linkedlist

The underlying data structure is linked list, query slow, delete quickly.

Thread insecure, high efficiency

|---Set (stored unordered, element unique)

|---HashSet

The underlying data structure is a hash table.

Relying on the hashcode () and Equals () two methods to ensure the uniqueness of the element, the development of the use of development tools automatically generated just fine.

|---linkedhashset

The underlying data structures are linked lists and hash tables

Chain List guarantees orderly elements

Hash table guaranteed Element unique

|---TreeSet

The underlying data structure is a red-black tree.

How do you ensure that elements are sorted? Natural sort or comparator sort.

How do you ensure that elements are unique? Judging by whether the comparison results are zero.

Map

|---HashMap

The bottom is the array list, using the hash algorithm to ensure that the element storage location

|---linkedhashmap

|---TreeMap

The bottom layer is the red and black tree implementation.

Summary of common data structures in collections

ARRAYXXX: The underlying data structure is an array, query fast, and delete slowly
LINKEDXXX: The underlying data structure is linked list, query slow, and delete quickly
HASHXXX: The underlying data structure is a hash table. Dependent on two methods: Hashcode () and Equals ()
TREEXXX: The underlying data structure is a two-fork tree. Sort by two ways: natural sort and comparator sort

The difference between collection and collections?

1.Collection is the top-level interface of a single-column collection with two sub-interfaces list and set

2.Collections is a tool class that operates on a collection and can be sorted and looked up

Java Collection, Map Collection Summary

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.