· 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.
HashMap· It is a Map,which means it stores 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