[Java learning notes] Map, learning notes map

Source: Internet
Author: User

[Java learning notes] Map, learning notes map
Map:

Add one element at a time, also known as a double row set.

WhileCollectionAdd an element at a time, called a single column set.

 

Common Methods: 1. Add

Value put (key, value); returns the value associated with the key. If not, null is returned.

2. Delete

Void clear (); clears the map set.

Value remove (key); returns the value associated with the specified key and deletes the key-value pair. If no key is specified, null is returned.

3. Judgment

Boolean containsKey (key );

Boolean containsValue (value );

Boolean isEmpty ();

4. Get

Value get (key): get the value through the key. If the key is not found, null is returned. Of course, null can be returned to determine whether the specified key is included.

Int size (); gets the number of key-value pairs.

 

Common subclass of Map: | -- HashTable:

The internal structure is a hash table, which is synchronous and does not allow null as the key or null as the value.

| -- Properties: stores information about key-Value Pair configuration files, which can be combined with IO technology.

| -- HashMap:

The internal structure is a hash table, not synchronous. Allow null as the key and null as the value.

| -- TreeMap:

The internal structure is a binary tree, not synchronous. You can sort keys in the Map set.

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.