Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6683551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:50:05+00:00 2026-05-26T04:50:05+00:00

I am trying to write a Java class where the main method creates an

  • 0

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); 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:50:06+00:00Added an answer on May 26, 2026 at 4:50 am

    The clue is in your comment:

    LOAD(); // the job of this method is to populate this array
    

    So you’ve got an array that you want the method to work with… you should pass it to the method:

    load(randomThirty);
    
    // Method declaration change...
    public static void load(int[] arrayToFill)
    

    That’s a good approach when a method isn’t naturally in the context where it has access to state. In this case is looks like the appropriate approach. For other situations, you could use a static or instance variable, depending on the context.

    (You should look at the Random class, by the way – and learn about Java naming conventions.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a Java class to extract a large zip file
I'm trying to call the java code from S. This method call: cls =
I am trying to write a java ZIP util class as below: package fdbank.util;
I'm trying to write a quick little java application to read the contents of
I am trying to write a unit test for an action method which calls
What's up y'all, I am trying to write some code in Java that will
I am new to programming and Java and trying to write a program which
In the following example, I'm trying to use sun.tools.javac.Main to dynamically compile a class
Hey guys, am trying to write to do type casting in java, but i
I'm trying to write a simple game in Java that uses Processing to render

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.