Category: Java Programs

Difference Between Queue and Stack in Java

Published on:

Criteria Queue Stack Data Structure Type FIFO (First-In-First-Out) LIFO (Last-In-First-Out) Primary Operations offer (or add), poll (or remove), peek push,...

Read More

Java ConcurrentHashMap CRUD Operations Example

Published on:

ConcurrentHashMap is a part of the Java Collections Framework designed for concurrent use by multiple threads. It provides thread-safety without...

Read More

Java TreeMap CRUD Operations Example

Published on:

A TreeMap is a part of the Java Collections Framework and extends the AbstractMap class. It is a Red-Black tree-based...

Read More

Java LinkedHashMap CRUD Operations Example

Published on:

LinkedHashMap is a subclass of HashMap that maintains a doubly-linked list running through all its entries. This ensures the order...

Read More

Java HashMap CRUD Operations Example

Published on:

HashMap is a part of the Java Collections Framework and is found in the java.util package. It is a data...

Read More

Java TreeSet CRUD Operations Example

Published on:

TreeSet is an implementation of the SortedSet interface in Java, which uses a Red-Black tree as its backend. It ensures...

Read More

Java LinkedHashSet CRUD Operations Example

Published on:

LinkedHashSet is a part of the Java Collections Framework and resides in the java.util package. It's an ordered version of...

Read More

Java HashSet CRUD Operations Example

Published on:

HashSet is a part of Java's collection framework and is present in the java.util package. It implements the Set interface...

Read More

Java LinkedList CRUD Operations Example

Published on:

LinkedList is a part of the collection framework in Java and resides in the java.util package. Unlike ArrayList, the LinkedList...

Read More

Java ArrayList CRUD Operations Example

Published on:

In Java, ArrayList is a part of the collection framework and resides in the java.util package. It provides dynamic arrays...

Read More

How to Sort Custom Objects in Java 8

Published on:

Java 8 introduced a plethora of new features and enhancements, particularly in the area of collections and stream processing. Among...

Read More

Java Comparator Handling Null Values

Published on:

In Java, when sorting collections using a Comparator, handling null values can be tricky. By default, using a comparator on...

Read More

Java Comparator Sorting by Multiple Fields

Published on:

In Java, the Comparator interface is used tool for defining custom orderings for collections of objects. Sometimes, we need to...

Read More

Java Comparator in Reverse Order

Published on:

Often in programming, there is a need to sort collections in reverse order. Java provides the Comparator interface, which is...

Read More

Java Lambda Comparator with Multiple Fields

Published on:

In many real-world scenarios, sorting data based on a single field might not suffice. There might be a need to...

Read More

Java Comparator with Lambda Expressions

Published on:

The Comparator interface is a powerful tool in Java to define custom orderings for collections of objects, especially when you...

Read More

Java Comparator with Lambda to Sort in Descending Order

Published on:

With the introduction of Java 8, lambdas brought a more concise and expressive way to implement interfaces with a single...

Read More

Java Comparator in Ascending Order

Published on:

In Java, the Comparator interface provides a powerful mechanism to define custom ordering for collections of objects. Often, we need...

Read More

Java Comparator in Descending Order

Published on:

In Java, the Comparator interface is used to order the objects of user-defined classes. If you want to order objects...

Read More

Delete Middle Element From Stack in Java

Published on:

In many applications, there might arise a need to modify the content of a stack. One such modification can be...

Read More

Reverse an Array Using Stack in Java

Published on:

Reversing an array is a fundamental problem in computer science. While there are several methods to reverse an array, using...

Read More

Reverse a String Using Stack in Java

Published on:

Reversing a string is one of the classical problems in the field of computer science. One of the most efficient...

Read More

Convert Singly Linked List Into Circular Linked List in Java

Published on:

A singly linked list is a type of data structure where each node points to the next node in the...

Read More

Deletion in Linked List in Java

Published on:

Deletion is one of the primary operations in a linked list, allowing us to remove a node based on its...

Read More