Java Learning Notes (1) __java

Source: Internet
Author: User
HashMap        It is a map,which means it stores <key, value> pairs. Same key with different Valueswill is stored once in the "map" and only the "last one" into map would bestored, i.e. W Hen a value into the map, if the key already exists, thevalue'll be replaced by the new one, which means for you wil L LOSE the value.
       It uses hashfunction. Objects for key must override the Hashcode () method inherited the Fromclass object. HashMap Re-hash The returned value of Hashcode () to find Thebucket. The reason of re-hashing is to avoid poor quality hash functions.
       When twodifferent keys have the same hash code, Euqals () method comes to rescue . The
       null key andnull value are allowed in HashMap.
       Note This theimplementation of HASHMAP is not synchronized.
ArrayList VS Vector · Vector issynchronized while ArrayList are not.
· Vector is slow as it thread safe. In Comparisonarraylist is fast
· By default, a vector double the size of it array whenneeded, and ArrayList increases its array size by 50%
Thread Safety The following description is from Wikipedia.
· Thread Safety ISA computer Programming concept applicable in the context of Multi-threadprograms
· A piece of Codeis thread safe if it manipulatesshared data structures only in a manner that guarantees safe execution Bymu Ltiple threads
at the same time.

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.