I am trying to compare which has a greater quotient when multiplying adjacent elements:
public static void main(String args[]) {
int[] inputArray = {-5, 8, -9, 1, -5, 4};
int x = 0;
long maxsofar = 0;
while (x < inputArray.length - 1) {
int currentmax = inputArray[x] * inputArray[x + 1];
maxsofar = (maxsofar > currentmax) ? maxsofar : currentmax;
}
x++;
}
System.out.println(maxsofar);
}
So far my code works, but when I try to use negative integers on my array, it just outputs 0.