Answers for "how to make arraylist only remove one thing and leave the duplicates"

3

java remove duplicates

import java.util.*;

public class RemoveDuplicatesFromArrayList {

    public static void main(String[] args) {
        List<Integer> numbers = Arrays.asList(1,2,2,2,3,5);

        System.out.println(numbers);

        Set<Integer> hashSet = new LinkedHashSet(numbers);
        ArrayList<Integer> removedDuplicates = new ArrayList(hashSet);

        System.out.println(removedDuplicates);
    }
}
Posted by: Guest on June-12-2020

Code answers related to "how to make arraylist only remove one thing and leave the duplicates"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language