Get Unique Values from ArrayList in Java Last Updated : 11 Dec, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Let's see how to get unique values from ArrayList. Convert ArrayList to HashSet to insert duplicate values in ArrayList but on the other hand, HashSet is not allowing to insert any duplicate value. While converting ArrayList to HashSet all the duplicate values are removed and as a result, unique values are obtained. Example: INPUT : ArrayList = [a, b, c, b, d, a, c] OUTPUT: Unique = [a, b, c, d] INPUT : ArrayList = [1, 5, 2, 4, 3, 4, 5] OUTPUT: Unique = [1, 2, 3, 4, 5]Approach: Create a ArrarList.Add elements in ArrayList.Create HashSet and pass in HashSet constructor.Print HashSet object.Below is the implementation of the above approach: Java // Get Unique Values from ArrayList in Java import java.util.ArrayList; import java.util.HashSet; public class GFG { public static void main(String[] args) { // Create ArrayList ArrayList<String> ArrList = new ArrayList<String>(); // add values in ArrayList ArrList.add("a"); ArrList.add("b"); ArrList.add("c"); ArrList.add("b"); ArrList.add("d"); ArrList.add("a"); ArrList.add("c"); // display original ArrayList System.out.println("Original ArrayList is : " + ArrList); // convert ArrayList to HastSet. HashSet<String> hset = new HashSet<String>(ArrList); // display HastSet System.out.println("ArrayList Unique Values is : " + hset); } } OutputOriginal ArrayList is : [a, b, c, b, d, a, c] ArrayList Unique Values is : [a, b, c, d] Time Complexity: O(n), where n is the length of the original ArrayList. Comment More infoAdvertise with us Next Article Finding the Minimum or Maximum Value in Java ArrayList S sidgautam Follow Improve Article Tags : Java Technical Scripter Java Programs Technical Scripter 2020 Java-ArrayList +1 More Practice Tags : Java Similar Reads Finding the Minimum or Maximum Value in Java ArrayList The minimum value is the one with the smallest value and the maximum value is the one with the largest value. The main task here is to find the minimum and maximum value from the ArrayList. Consider an example of an ArrayList, and we need to find the largest and the smallest element. Example: Input 5 min read Convert ArrayList to Vector in Java There are several ways to convert ArrayList to Vector. We can use a vector constructor for converting ArrayList to vector. We can read ArrayList elements one by one and add them in vector. Approach 1: (Using Vector Constructor) Create an ArrayList.Add elements in ArrayList.Create a vector and pass t 3 min read How to Serialize ArrayList in Java? ArrayList is a class under the collections framework of java. It is present in java.util package. An ArrayList is a re-sizable array in java i.e., unlike an array, the size of an ArrayList can be modified dynamically according to our requirement. Also, the ArrayList class provides many useful method 2 min read How to Declare an ArrayList with Values in Java? ArrayList is simply known as a resizable array. Declaring an ArrayList with values is a basic task that involves the initialization of a list with specific elements. It is said to be dynamic as the size of it can be changed. Proceeding with the declaration of ArrayList, we have to be aware of the co 2 min read Get Enumeration Over Java ArrayList ArrayList class is a re-sizeable array that is present in java.util package. Unlike the built-in arrays, ArrayList can change their size dynamically where elements can be added and removed from an ArrayList. In java version 1, enum was not present. With advancement to version, 1.5 enum was introduce 3 min read How Objects Can an ArrayList Hold in Java? ArrayList is a part of the collection framework and is present in java.util package. It provides us with dynamic arrays in Java just as Vector in C++. Though, it may be slower than standard arrays but can be helpful in programs where lots of manipulation in the array is needed. In order to understan 3 min read Like