It's been asked before, I know, but I really don't know why my code isn't working. I'm trying to figure out how many unique values are in an undefined array. (i.e. {0, 0, 1, 1, 1, 5, 5, 6, 6, 7} should return a value of 5. This is what I have so far:
public static int numUnique(double[] list) {
int counter = 0;
for(int i = 0; i < list.length; i++) {
for(int j = i + 1; j < list.length; j++) {
if(list[i] != list[j])
counter ++;
}
}
return counter;
}