Java Gists

Remove Duplicates from List Using HashSet

The Set is also an interface in the 'Java Collection' framework. Unlike a List, a Set does not allow duplicates. Hence you can use a Set to eliminate the duplicates in a List. There are several ways in which you can use a Set to eliminate duplicates as...

Convert List to Array Using Stream without Param

Java 8 has added the Stream API that helps to easily perform bulk operations on Collections. A new method called stream() has been added to all the collection interfaces that returns a Stream corresponding to the underlying collection. There is a toArray method available on the Stream interface that can...

Remove Duplicates from List Using For-Loop

The simplest way to remove duplicates from a 'List' is to use a for-loop. The following code snippet demonstrates this method. First, the code creates a new ArrayList to store the output, i.e. a List without duplicates. A for-loop is then used which iterates through the input List. It first...

Convert List to Array Using For-Loop

The simplest way to convert a List to an array is to use a for-loop. The following code snippet demonstrates this method. First, the code creates an Array based on the number of elements in the input List. A for-loop is then used which iterates through the input List and...

POPULAR | JAVA GISTS

POPULAR | TAGS

LATEST POSTS

CronTab Basic Commands With Examples

Cron is a time-based job scheduler in Unix-like operating systems, which is used to automate repetitive tasks. It is a daemon (a background process)...

Basic PowerShell Commands That You Should Know

One of the key benefits of PowerShell is its object-oriented nature. Instead of working with text-based output like traditional command-line interfaces, PowerShell returns objects...

How To Always Open Files in New Tab in VSCode

The VSCode has rocketed its way to one of the top development IDEs due to its fresh look, usability, tons of feature sets, and...

TOP | CATEGORIES

Most Commented

Interpreted Vs Compiled Languages

This is based on an excerpt from one of my favourite literature on VBScript and in fact, is quite relevant with respect to one of...