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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:02:46+00:00 2026-06-18T06:02:46+00:00

I am having a problem with trying to keep my coding organized and as

  • 0

I am having a problem with trying to keep my coding organized and as simple as possible. I basically have an array of similar objects that hold multiple values. I am wanting to access those individual values and be able to modify them at will but cannot seem to acess them. This is what the code basically looks like…

    //In file Champion.java
    package Champions;
    public interface Champion{}

    //In another file ChoGath.java
    package Champions;
    public class ChoGath implements Champion{
    public static double health = 440.0;
    }

    //Yet another file Ahri.java
    package Champions;
    public class Ahri implements Champion{
    public static double health = 380.0;
    }

    //In the main build file LOLChampBuilder.java
    package LOLChampBuilder;
    import Champions.*;
    public class LOLChampBuilder{
        public static Champion[] listOfChampions = {new ChoGath(), new Ahri()};
        public static void main(String args[]){
            //This next line works
            System.out.println(new ChoGath().health);
            //This next line does not work
            System.out.println(listOfChampions[0].health);
        }
    }

There are more variables and whatnot but this is the basic problem.

ChoGath and Ahri are part of the group Champions and each has their own unique value for health. I want to be able to combine it all into an array for ease of grabbing values because I know where ChoGath (as an example) is in the array.

I get the error Cannot find symbol 'health' in Champions.Champion. I have gone and created the value in Champion and that fixes it (and also change it to class and then extends instead of implements) but then when I go to print the value is always 380.0 as it was the most recent edit to the value health in Champion.

I want it so that I can group all the “Champions” together under a single array (so they need to be the same object type ie: Champion, correct me if I’m wrong) and access their individual values. I cannot seem to do this so I don’t know if I need to use ArrayList (which I’ve never used) or something else entirely. Now I know I could fix this and put it all into a massive file but I am trying to use multiple files for organizational purposes as well as cleanliness. Thoughts on what to do?

  • 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-18T06:02:47+00:00Added an answer on June 18, 2026 at 6:02 am

    You need to add getHealth() to your interface. That’s what getters are for.

    Also avoid the use of static variables. They tend to produce programming errors.

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

Sidebar

Related Questions

I have been having a small problem that I can't by-pass it, I keep
I keep having this problem when trying to run inside directory that has server
I'm having a problem trying to create a Javascript function that checks all the
I'm having a problem when trying to pass an array back to a COM
I am having problem that when i am trying to submit the form by
I have been having this annoying problem when trying to implement a picture gallery
I´m encountering this problem trying to mock some objects that receive complex lambda expressions
I have a problem I am trying to solve as smooth as possible, and
I'm having a problem formating an xpath query. I'm trying to get products that
I am having a problem trying to get my program to keep information in

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.