I am trying to write a Java class where the main method creates an array to store 30 integers. Afterwards, I call a method called LOAD() in the main method, whose job is to populate the array with 30 integers from 1-300.
I have written what I think is a complete Java class to do this, yet the compiler keeps telling me this error of that it cannot find the symbol
for symbol randomThirty, my array variable's name.
Here is my code so far, yet I am not sure why my randomThirty is not being picked up by LOAD(), perhaps I need to pass the parameters explicitly in the parens of LOAD?
import java.util.*;
public class arrayNums
{
public static void main(String args[])
{
//main method which creates an array to store 30 integers
int[] randomThirty = new int[30]; //declare and set the array randomThirty to have 30 elements as int type
System.out.println("Here are 30 random numbers: " + randomThirty);
LOAD(); // the job of this method is to populate this array with 30 integers in the range of 1 through 300.
}
public static void LOAD()
{
// looping through to assign random values from 1 - 300
for (int i = 0; i < randomThirty.length(); i++) {
randomThirty[i] = (int)(Math.random() * 301);
}