WeakHashMap in Java

What is WeakHashMap WeakHashMap is based on Hash table implementation of the Map interface but with weak keys. An entry in a WeakHashMap will automatically be removed when its key is no longer in ordinary use. When a key has been discarded due to weakness characteristics of keys its entry is effectively removed from the map, so this class behaves…

LinkedHashMap in Java

What is LinkedHashMap A LinkedHashMap like HashMap is a simple yet powerful way to store and get data. Unlike HashMap, LinkedHashMap is based on HashTable and Linked list implementation of the Map interface and stores items as key/value pairs. Like HashMap, LinkedHashMap permits only unique keys. It also permits only one null key (whereas HashTable does not allow any null…

HashMap in Java

What is HashMap A HashMap is a simple yet powerful way to store and get data. HashMap is based on HashTable implementation, that implements the Map interface and stores items as key/value pairs. HashMap permits only unique keys. It also permits only one null key (whereas HashTable does not allow any null key) but may have more than one null…

ConcurrentHashMap in Java

Though we have thread-safe collections classes like HashTable, Synchronized Map, which can be used in multi-threaded environment but there are significant differences between them, which arise from the fact that how they achieve their thread-safety. All methods of Hashtable are synchronized which make them quite slow due to the number of thread increases. Synchronized Map is also similar to the…

Java CyclicBarrier

A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point. CyclicBarriers are useful in programs involving a fixed sized party of threads that must occasionally wait for each other. The barrier is called cyclic because it can be re-used after the waiting threads are released. A CyclicBarrier supports an…

Java CountDownLatch

What is CountDownLatch? A synchronization aid that allows one or more threads to wait until a set of operations being performed in other threads completes, i.e., a kind of synchronization tool that allows one Thread  to wait for one or more Threads before it starts processing. How does CountDownLatch work? A CountDownLatch is initialized with a given count. The await…

Searching an element in Java ArrayList

This tutorial example will show you how to search an element in Java ArrayList in both case sensitive and case insensitive way.

Handling large data writing to Excel using SXSSF Apache POI

Large Data Writing to Excel This tutorial will show you an example on handling large data writing to excel using sxssf Apache POI library. Having said that I will show you here how to write large data set to an Excel file using Apache POI using SXSSF. The theoretical text and concept have been borrowed from http://poi.apache.org/spreadsheet/how-to.html#sxssf SXSSF (package: org.apache.poi.xssf.streaming)…

Java 8 Date and Time API

Introduction Here I am going to discuss about the Java 8 or later version’s new date and time API. The date time package, java.time, was introduced in the Java SE 8 release, which provides a comprehensive model for date and time. The new date and time API offers greatly improved safety and functionalities for developers.

Java 8 Stream API

Introduction In this tutorial I will explain about Java’s new API called stream, which was introduced in Java 8 and included in package java.util.stream. The stream API supports functional-style operations on collection of elements or stream of elements in a collection.