Author name: javaplanet.io

Choosing the right data structure based on requirements

1. Understand Your Requirements Criteria Description Data Operations Identify primary operations: insert, delete, search, traversal, etc. Concurrency Will multiple threads access/modify the structure concurrently? Order Is ordering important (sorted, FIFO, LIFO)? Memory Efficiency Is minimal memory usage critical, especially for large datasets? Performance How frequent and large are the operations? Optimize for speed if needed.

Choosing the right data structure based on requirements Read More »

ConcurrentLinkedQueue

ConcurrentLinkedQueue in Java is a concurrent, unbounded queue implementation that provides thread-safe operations for high-performance, scalable handling of elements in a FIFO (First-In-First-Out) manner. It is part of the java.util.concurrent package and is designed for scenarios where multiple threads need to access a queue concurrently without explicit synchronization. The syntax for creating a ConcurrentLinkedQueue is

ConcurrentLinkedQueue Read More »

ConcurrentHashMap

java.util.concurrent.ConcurrentHashMap is a part of the Java Concurrency package and is designed for highly concurrent applications. It is an advanced version of HashMap that allows safe access and modification by multiple threads without the need for external synchronization. Let’s consider a ConcurrentHashMap<String, Integer> that stores the marks of 5 students: Paani, Mahesh, Datta, Ganesh, and

ConcurrentHashMap Read More »

Shuffling

Shuffling in Java refers to the process of randomly reordering elements within a collection, typically an array or a list. This can be useful in various scenarios such as randomizing quiz questions, shuffling a deck of cards, or generating random permutations of data. Java provides a convenient way to shuffle collections through the Collections class

Shuffling Read More »

Scroll to Top