Here's my method:
public int randomIntegers() {
array = new int[20];
Random r = new Random();
for(i =0; i<20; i++) {
int intRandom = r.nextInt(1000);
if (intRandom >= 100) {
array[i] = intRandom;
}
}
return array[i];
}
Println:
System.out.println(array[i]);
And when I use println in the main method, I get a NullPointerException. Have honestly tried to conceptually understand why this isn't working, to no avail.
ibefore printing. And also - are you initializing the array before calling theprintstatement?ideclared? I think you need to show the whole file.