Unique values of an array
No need for any loops with Java 8 streams.


Get a DoubleStream from the array with Arrays.stream(double[] array) so that you can
get the distinct() elements from that
which you can count() to retrieve your result.




public static long numUnique(double[] list) 
{
    return Arrays.stream(list).distinct().count();
}


As count() returns a long, I modified the signature of your method to return long, too. It's within the responsibility of the user of your method then to perform any cast on the result.

Full example program:

import java.util.Arrays;

public class UniqueDoubles
{
    public static void main(String[] args)
    {
        double[] doubles = {1, 2, 3.5, 3.5, 2, 345345.345345};

        System.out.println(numUnique(doubles));
    }

    public static long numUnique(double[] list) 
    {
        return Arrays.stream(list).distinct().count();
    }
}