Java How To -Remove Duplicates from an Array
How To Remove Duplicates from an Array
Convert an array into aSet to remove duplicates:
Example
import java.util.Arrays;import java.util.HashSet;import java.util.Set;public class Main { public static void main(String[] args) { Integer[] numbers = {1, 2, 2, 3, 4, 4, 5}; Set<Integer> unique = new HashSet<>(Arrays.asList(numbers)); System.out.println(unique); }}
