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

  • Home
  • SEARCH
  • 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 7860645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:22:20+00:00 2026-06-02T22:22:20+00:00

I’m having trouble with a little program I’m making. Basically I have 6 Classes.

  • 0

I’m having trouble with a little program I’m making. Basically I have 6 Classes. 1 main class, 4 sub classes that “extend” the main class and another class to run the program. The class to run the program is laid out this so far:

public class ClassToRunProgram {

public void main(String[] args){

Class1 a = new Class1(0, "class1"); //I've created 1 main class (Class5) that 
Class2 b = new Class2(1, "class2"); //these 4 classes extend.
Class3 c = new Class3(2, "class3");
Class4 d = new Class4(3, "class4");

int randomNum = (int) (Math.random() *3);

Class5[] arrayForClasses = new Class5[]{a, b, c, d}; //since they're extending this
                                                    //class I want to make them into
                                                   //a single Array?


    String numberQuestion = JOptionPane.showInputDialog(null, 
"What question do you want to ask? \n 
Enter a number: \n 
1. First Question? \n 
2. Second Question? \n 
3. Third Question?");

int question = Integer.parseInt(numberQuestion); //not sure if this part is 
                                                //actually relevant at all??
                                               //Think it might be since I want to
                                              //use integers in my if statement below


if(question == 1){
    JOptionPane.showMessageDialog(null, "Blah blah"+arrayForClasses.getReturnValue()+" blah");
}

The .getReturnValue() method is within all of the classes (1-5). I’m not sure if this is actually what I have to do. But the problem I’m having is that when I compile it (even though it’s not finished) it throws up a “CANNOT FIND SYMBOL” error with the message “symbol: method .getReturnValue() location: variable arrayForClasses type Class5[]”. I’m just wondering where am I going wrong with this?

Any help is much appreciated.

Thanks!

  • 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-06-02T22:22:22+00:00Added an answer on June 2, 2026 at 10:22 pm

    arrayForClasses is an array, and you can’t ever add methods to arrays, only to the objects inside the arrays. You need to call the method on the objects in the array, not the array itself. So something like

    arrayForClasses[0].getReturnValue()
    

    Now, I say “something like” because I’m having a hard time following what you’re trying to do, and I’m a little concerned about this idea of putting the “getReturnValue()” method into many different classes without a specific reason to do so.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has

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.