I\'m writing a code where I have an int[a] and the method should return the number of unique values. Example: {1} = 0 different values, {3,3,3} = 0 different values, {1,2} = 2 d
What about this?
private int arrayDistinctCount(T[] array) { return Arrays.stream(array).collect(Collectors.toSet()).size(); }