In the second if statement when I'm comparing values[i] and values[secondIdx], why doesn't this cause an error seeing as secondIdx is equal to -1?
public static int getSecondMinIndex(int[] values) {
int secondIdx = -1;
int minIdx = getMinIndex(values);
for (int i = 0; i < values.length; i++) {
if (i == minIdx)
continue;
if (values[i] < values[secondIdx] || secondIdx == -1)
secondIdx = i;
}
return secondIdx;
}