Beginner in Java.
I am trying to find the highest value and lowest value of an array.
The highest value works perfectly fine, while the lowest value keeps on giving me 0, even though 0 is not part of the array. Below is the code. Thanks.
mxm = n [0];
for (x = 1 ; x <= 15 ; x++)
{
if (n [x] > mxm)
{
mxm = n [x];
}
}
c.println ("The largest integer out of the 15 generated is " + mxm);
min = n [0];
for (x = 1 ; x <= 15 ; x++)
{
if (n [x] < min)
{
min = n [x];
}
}
c.println ("The smallest integer out of the 15 generated is " + min);