Thank you for both your responses. I inspected my code carefully after finding some errors and fixed some logical mistakes that did not show up in the error reports.
Thank you for your in depth responses, it has helped me immensely.
This is my new code that works.
public class LargestRandom {
public static void main(String[] args) {
// create array with 100 integers
int N = 100;
int[] randoms = new int [N];
int n;
int largestr = 0;
// fill array with 100 values ranging from 0 to 100
for (int i = 0; i<randoms.length; i++){
randoms[i] = (int) (Math.random()*100);
// find the largest value in the array
if (i > 0){
n = randoms[i];
if (n > randoms[i-1])
largestr = n;
}
}
System.out.println("The largest variable is " + largestr);
}
}