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 6832245
In Process

The Archive Base Latest Questions

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

I am trying to make an array of objects. I have Two classes, the

  • 0

I am trying to make an array of objects. I have Two classes, the main and another class for the methods. The one i am running the program in is TestTrivia, the class with all the methods for TestTrivia is Question. Constructor for this class is
public Question()
{
question = “null”;
answer = “null”;
pointValue = 0;
}
i am trying to do something like this
Person personArray[] = new Person[5];

   for(int i=0; i< personArray.length; i++)
   {
    personArray[i] = new Person();
  }

So i have tried
Question QuestionArray[] = new Question[5];
for(int i=0; i< QuestionArray.length; i++)
{
QuestionArray[i] = new Question();
}
I have tried to use it in both classes, the main and the one full of methods. It should go into the main class correct? The error i am getting is the whole for statement is underlined and says: illegal start type cannot find symbol symbol: class i location: class triviagame.TriviaGame package QuestionArray does not exist
triviagame is the package name, “TriviaGame” is the class name, “Question” is another class name.

  • 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-26T22:50:08+00:00Added an answer on May 26, 2026 at 10:50 pm

    The loop code needs to be within a method, like main.

    Also, if they are not in the same package, you will need to import classes not in the “current” package. For example, if Question is in the default package, it will need to be imported into the TriviaGame class.

    package triviagame;
    
    import Question;
    
    public class TriviaGame {
        public static void main(String[] args) {
            System.out.println("Welcome to the New Age Trivia game");
            System.out.println("You will be asked five questions, let us begin");
            Question questionArray[] = new Question[5];
            for (int i = 0; i < questionArray.length; i++) {
                questionArray[i] = new Question();
            }
        }
    }
    

    If the Question class is in the triviagame package as well, the import is unnecessary.

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

Sidebar

Related Questions

I am trying to make a two dimensional array out of two one dimentional
I'm trying to make an array of objects (animalImages) from a plist file which
In PHP, if you make an array of objects, are the object methods (not
I was trying to make an array-based linear list, then I compiled this: char
I am trying to make an array of strings and then pluck a random
I'm trying to make a dynamic array in C# but I get an annoying
I'm writing some error checking and trying to make use of an boolean array
I'm trying to subclass Array in ruby to make it randomize its elements when
I am trying to make decision how to design my app. I have about
I'm trying to design a class hierarchy with a bunch of similar classes that

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.