Initial knowledge of the Java collection--hash table (HashTable)

Source: Internet
Author: User

The hash table calculates an integer for each object, called a hash code (an integer generated by an instance field of the object), or more precisely
* Different instance domain objects produce different hash codes
*
* If the custom class is responsible for implementing the hashcode of this class, note that the Hashcode method that you implement should be compatible with the Equals method
* That is, if A.equals (b) is true A and B must have the same hash code
*
* In Java, the hash table is implemented with a list of linked arrays. Each list is called a bucket. To find objects in a table, calculate the hash code first and then take the remainder of the bucket
* The remainder is the index of the bucket. When there is no other element in the bucket, it is lucky to be put in, and if the bucket is full, compare the new object with the bucket first
* See if it exists.
*
* The number of buckets in the standard class library is a power of 2, the default is 16, and if the hash list is too full, a hash (rehashed) will create a table with more buckets and all the elements
* INSERT into this new table, then discard the original table.
* The reload factor determines when the hash list is hashed. General Default 0.75
*
*
* The hash table can implement several important data structures, the simplest of which is "Set"
*
* Set's add will now focus on finding the object to be added, and if it doesn't exist, add the object
*

Initial knowledge of the Java collection--hash table (HashTable)

Related Article

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.