Collections

Set to List in Java

How to Convert Set to List in Java

Lists in Java are ordered collection of data, whereas sets are an unordered collection of data. A list can have duplicate entries, a set can not. Both the data structures are useful in different scenarios…..

MERGELISTS IN JAVA

How to Merge Two Lists in Java?

Merging two lists in Java is often a useful operation. These lists can be ArrayLists or LinkedLists. How to Merge Two Lists in Java There are multiple ways we can merge two lists in Java…..

HashMap implementation in Java using List

HashMap is one of the most widely used implementation of Map to store key-value pairs. It has been introduced in Java 1.2 and here I am trying to implement HashMap with ArrayList. The below code will provide two of the basic HashMap functions i.e get(key) and put(key, value). The code also takes care of checking duplicate values while storing.

Please note that its just the basic implementation and should not be used as a replacement of HashMap. Also while testing the code, make sure that the Object used in the KEY has proper implementation of equals() method.

ConcurrentHashMap in Java

If you are a Java Developer, I am sure that you must be aware of ConcurrentModificationException that comes when you want to modify the Collection object while using iterator to go through with all its element.

Java 1.5 has introduced java.util.concurrent package with Collection classes implementations that allow you to modify your collection object at runtime.

ConcurrentHashMap is the class that is similar to HashMap but works fine when you try to modify your map at runtime.

close
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages