In “How HashMap works in Java“, we learned the internals of HashMap or ConcurrentHashMap class and how they fit into the whole concept. But when the interviewer asks you about HashMap related concepts, he does not stop only on the core concept. The discussion usually goes in multiple d...
9. Difference betweenHashtableandHashMapin Java? (former is thread-safe and doesn't allow null, later is not thread-safe, former is also slow because of whole locking of Map, whileHashMapis fast because of no locking,read more) 10. Difference betweenArrayListandLinkedListin Java? (former i...
1. What is Java HashMap? Java HashMap is a collection that implements from the Map interface. It has been around since JDK 1.2. HashMap is implemented on top of HashTable and therefore they both have a lot of similarities. HashMap in Java stores key-value pairs and provides several ...
160) What is the default size of ArrayList ,HashMap,HashSet,HashTable,Vector in Java? 161) What is the load factor, capacity, and Size of the Collection in Java? 162) What is the difference between fail-safe and fail-fast Iterator in Java? 163) How do you find if an ArrayList conta...
has seen this question on core Java or J2EE interview. Well there are many difference between them but most important isthread-safety,HashMapis not thread-safe whileHashtableis thread-safe collection. SeeHashtable vs HashMap in Javafor more differences between HashMap and Hashtable in Java. ...
How is dependency injection achieved in Java? Dependency injection (DI) is a design pattern where objects are inserted into a class rather than having the class create them itself. DI is attained via frameworks like Spring in Java. What is the difference between HashMap and HashTable in Java...
Explain the difference betweenpublic,private,protected, anddefaultaccess modifiers in Java. String,StringBuilder,StringBuffer HashMap,LinkedHashMap,ConcurrentHashMap What is the purpose of theExceptionclass in Java? TheExceptionclass is the base class for all exception types in Java. It represents an ...
How HashMap works in Java?HashMap stores key-value pair in `Map.Entry` static nested class implementation. HashMap works on hashing algorithm and uses hashCode() and equals() method in `put` and `get` methods. When we call `put` method by passing key-value pair, HashMap uses Key ...
9. How to get data from HashMap? //howtodoinjava.com/java/interviews-questions/how-hashmap-works-in-java/ 10. Difference between Vector and ArrayList? //howtodoinjava.com/java/collections/useful-java-collection-interview-questions/ 11. Difference between sleep and wait?
ConcurrentHashMap: ConcurrentHashMap in Java versions before JDK 1.8 uses an array of Segments:Segment< K,V >[] segments Segment inherits from ReenTrantLock, so each Segment is a reentrant lock. Each Segment has aHashEntry< K,V >array to store data. During put operation, it is only necess...