ConcurrentHashMap in Java

ConcurrentHashMap is an alternative to HashTable and synchronizedMap. It is used in multi threaded applications and provided better performance when compared to HashTable and synchronisedMap. ConcurrentHashMap Implementation In Java In concurrentHashMap we have new feature called concurrency level . The ConcurrentHashMap is divided into segments based on the concurrency level.We need to be careful while […]

Fail fast & Fail safe Iterators in Java

Iterators are basically used to traverse over a set of objects one by one. Java supports two types of Iterators  Fail Fast Iterator Fail Safe Iterator Fail Fast Iterator Fail fast iterator do not allow any modifications to a collection while iterating/traversing the collection.By modification I mean any updating, addition of elements in the collection.If […]

How HashMap works in Java1.8?

HashMap is a hash table implementation of Map interface in Java. A map contains a collection of key-value pairs where key maps to the value.HashMap permits null values and null keys and it doesn’t permit duplicate keys.It is unordered so it doesn’t guarantee that the order will remain constant with time. Hashmap provides constant time […]

Default Methods In Java

Default methods allows us to add new functionality to new or existing interfaces without breaking the existing functionality of legacy code. Prior to Java 1.8 interfaces did not allow default interfaces and it was very difficult to modify an existing interface without impacting the class which implemented the interface.For instance if a new method is […]