Java 学习笔记(1)

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值