Java

 
Maven Logo – Java Cat page
HIbernate Logo – Java Cat Page
Java Logo – Java Cat page
 

JAVA | ALL

JAVA | HOW-TOs

JAVA | TUTORIALS

JAVA CLASSES

HIBERNATE

MAVEN

JAVA GISTS

JAVA POSTS

Remove Duplicates from List Using LinkedHashSet

Another implementation of the Set interface is LinkedHashSet. LinkedHashSet maintains the order of elements and helps to overcome the HashSet limitation. The following code demonstrates this: This code is quite similar to the one seen earlier, except that it uses a LinkedHashSet. The input List is passed as a parameter...

Java Tutorial #1 – Variables and Data Types

Table of Contents Introduction 1. Variables 2. Data Types Primitive Data Types Integer Data Types Decimal Data Types Character Data Types Boolean Data Types Reference Data Types Introduction Variables are names that are used to identify memory locations that store values. Each variable belongs to a particular data type. Data types determine...

Convert List to Array Using Stream with Param

There is an overloaded version of the Stream.toArray method which can be used to return a result array that is of the same data type as the input array. The following code demonstrates this: Firstly, the 'stream()' method is invoked on the input List which returns a Stream corresponding to...

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...
- Advertisement -

How To Convert List To Array in Java

A common scenario faced by programmers is to convert a Java List to an Array. A 'List' is part of the Collection Framework and is useful when the number of elements are unknown. An 'Array', on the other hand, is useful for fixed-size elements. However, in real-world programming, there are...

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...
- Advertisement -

POPULAR | TAGS

LATEST POSTS

TOP | CATEGORIES

LATEST | JAVA GISTS

Rounding Decimal Number With Java DecimalFormat

The DecimalFormat class has a method called setRoundingMode() which can be used for setting the rounding mode for DecimalFormat object. The setRoundingMode() accepts RoundingMode...

Format Decimal Numbers with Grouping Separator

The DecimalFormat class has a method called setGroupingSize() which sets how many digits of the integer part to group. Groups are separated by the...

Format Decimal Numbers using Strings Within Pattern

As mentioned in earlier posts, the java.text.DecimalFormat class is used to format decimal numbers via predefined patterns specified as String. Apart from the decimal separator,...
- Advertisement -