Dark Horse Programmer--java Collection framework (map and tools Class)

Source: Internet
Author: User
Tags set set

There are three sub-categories under the 1.MAP system:

HashMap
The underlying is a hash table data structure that can be stored in NULL keys and null values, not synchronized
---TreeMap
The underlying is a two-fork tree data structure, thread synchronization, which can be used to sort keys in the map collection

Like set, the bottom of the set is map.

When you add an element, if the same key appears, the value added by the thick will overwrite the value of the original key, and the Put method will return the overridden value

Two ways to remove 2.map collections:
(1) KeySet (): Deposit all the keys in the map into the set set because the set has an iterator
You can take all the keys in an iterative manner, and then get the values for each key according to the Get () method
The extraction principle of the Map collection: The map is converted to set and then iterated out
(2) Entrymap (): Returns the map's relationship map set<map.entry<k,v>>

Map.entry is actually an interface, and he's an internal interface in the map interface.

3. Two Collection tool classes: Collections,arrays

(1) The Aslist () method of the Arrays tool class
Aslist: Converts an array into a list collection, using the ideas and methods of the collection to manipulate elements in an array

Note: To convert an array to a collection, you cannot use the Zengshan method of the collection because the length of the array is fixed

If the elements in the array are objects, then the elements in the array are converted directly to the elements in the collection when they become collections.
If an element in the array searches for the base data type, the array will be present as an element in the collection

(2) Set conversions to arrays
An array of the specified type how long should the enemy be defined?
When the array length of the specified type is less than the size of the collection, a new array is created inside the method, and the length is the size of the collection
When the length of an array of the specified type rains heavily on the size of the collection, the array is not newly created, but the passed in array is used instead
So create a just fine array of optimal

Dark Horse Programmer--java Collection framework (map and tools Class)

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.