Hashmap in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Hashmap in java?

What is the difference between hashmap and hashtable? Can we use INTEGERS as Keys for accessing?

1st Oct 2020, 8:28 AM
Nishtha
Nishtha - avatar
1 Answer
+ 7
Nishtha HashMap -They are non-synchronised. -They aren't thread safe. -That means multiple threads can operate -same on map object at a same time. -Because it's not a thread safe so the -performance will be high. -Null insertion allowed for both key and value. Hashtable -They are synchronised. -They are thread safe. -That means only threads can operate a object at a time. -Because it's a thread safe so the performance will be low. -Null insertion not allowed for key and value. Yes you can use Integer as a key. For Internal working of Hashmap:- https://www.sololearn.com/post/501453/?ref=app
1st Oct 2020, 9:10 AM
P∆WAN M∆URY∆
P∆WAN M∆URY∆ - avatar