Category: Java

Stack implementation in Java

A stack is a linear data structure which follows the LIFO (last-in first-out) principle. That means the objects can be inserted or removed only at one end of it also called as top.

Main method in Java

In Java, every application must contain a main method which serves as an entry point for the application similar to the main function in C and C++. The JVM (Java Virtual Machine) starts its execution by invoking the main method of the specified class and main() will subsequently invoke all the other methods required by …

Queue Implementation in Java

A queue is a linear data structure which follows the FIFO (first-in first-out) principle. That means the object which is inserted first will be the first one out, followed by the object which was inserted next.

Convert HashMap to TreeMap in Java

In this post, we will see how to convert HashMap to TreeMap in Java. The resultant TreeMap should contain all mappings of the HashMap, sorted by their natural ordering of keys.

Concatenate Multiple Lists in Java

In this article, several methods to concatenate multiple lists in Java into a single list are discussed using plain Java, Java 8, Guava Library and Apache Commons Collections.