Java Collection Class Simple summary (re-learn)

Source: Internet
Author: User
Tags set set

Introduction to Java collection classes (re-learn)

a . Collection (collection), map interface The two should be parallel relations.

  1.MAP Introduction

The map is stored as a key value (Key-value) pair, with 2 values. Use key to find value (ex: name-phone, call by name), object created by map key is

Can not be repeated. Its two common subclasses: the HashMap class and the Hashtable class.

HashMap class: Unordered storage, key not allowed to repeat

Hashtable class: Unordered storage, key not allowed to repeat

The key value can be obtained by means of the map method keyset all key value, return is a set set, value can be used by the map method of the values method to get the value of full value. Then traverse through the iterator.

  2.Collection (Collection Parent interface)

Collection subinterfaces have (common interface) A value: list, set, queue, etc. these three interfaces the list interface and the set interface are sub-interfaces of the collection

(1) List interface:

The contents of the list can be duplicated, that is, they can have the same value. Example: Adding ("a") and ("a") are the common classes of implementations that are possible: the Arrarylist class and the vector class Arrarylist class are introduced in JDK1.2, using asynchronous processing, high performance, and non-thread-safe. Vector class is introduced in JDK1.0, the use of synchronous processing, low performance, belonging to the thread-safe.

(2) Set interface:

Can not repeat the content, but can be sorted, break into the order of its two commonly used subclasses: HashSet class and TreeSet class HashSet class is hashed, not stored in order (such as the input is alphabetical, but the output is random), is random, certainly can not be sorted;

TreeSet classes are stored in an orderly manner (such as in alphabetical order, although not entered alphabetically), this can be sorted.

two. Iterator interface :

The standard operation of the set output, as long as the collection is output with iterator, provides a way for the object to get the iterator in collection. Note that when you use the iterator output, you cannot remove the elements from the collection by removing the collection, otherwise an exception occurs.

    

            

  

Java Collection Class Simple summary (re-learn)

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.