Category Archives: Java Collection

How to Remove Duplicate Elements from ArrayList in Java

In this tutorial you will learn how to remove duplicate elements from arraylist in Java. We can remove repeated elements in arraylist by two ways. Using HashSet – Do not maintain the insertion order. Using LinkedHashSet – Maintain the insertion order.   First we create an ArrayList and add some duplicate elements to it. Now… Read More »

Convert Array to ArrayList in Java

In this tutorial you will learn how to convert array to arraylist in Java. There are mainly two ways to convert a Java array to arraylist. Using Arrays.asList() method Using Collections.addAll() method Below I have shared an example of each of these methods. In these examples we are converting string array to arraylist. Also Read: Convert… Read More »

Convert ArrayList to Array in Java

In this tutorial you will learn how to convert ArrayList to Array in Java. Mainly there are two ways to convert ArrayList to array. Using manual way Using toArray() method Below I have share an example for both the ways. How to Convert ArrayList to Array in Java Convert Using Manual Way In this method… Read More »

Java HashMap with Example

According to Object Oriented programming, objects are intended to behave like ‘black boxes’ that developers can use without the need to know how they work internally, but only using their public interface. Unfortunately this is not always true, sometimes it is important to have at least a basic idea of the internal implementation in order… Read More »