Java 學習筆記(1)__Java

來源:互聯網
上載者:User
HashMap ·       It is a Map,which means it stores <Key, Value> pairs. Same key with different valueswill only be stored once in the map and only the last one put into map will bestored, i.e. when you put a value into the map, if the key already exists, thevalue will be replaced by the new one, which means you will lose the first value.
·       It uses hashfunction. Objects for key must override the hashCode() method inherited 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.
·       null key andnull value are allowed in HashMap.
·       Note that theimplementation of HashMap is not synchronized.
ArrayList VS Vector ·       Vector issynchronized while ArrayList is not.
·       Vector is slow as it is thread safe. In comparisonArrayList is fast
·       By default, a vector double the size of its 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 bymultiple threads at the same time.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.