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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:45:14+00:00 2026-05-30T01:45:14+00:00

I asked this same question on javaprogrammingforums.com but it seems their website is down

  • 0

I asked this same question on javaprogrammingforums.com but it seems their website is down right now. So I couldn’t see what responses (if any) I got. Anyways, I am badly stuck on this Java HW assignment. What I have so far looks good in terms of completion, now it’s just getting the right values to appear. Pretend I have this:

(This is only part of the 2nd class of the two with the constructor, the other is the “tester”)

//private variables
boolean myP;
boolean myPla;
boolean myGl;
boolean myCa;

double myPlot;
int myCrust;

double myReduct;
double myNet;
double myGross;

boolean [] trshIt = {myP, myPla, myGl, myCa};
double [] CO2TrashEmissions = {184.0, 25.6, 46.6, 165.8};

//constructor
CO2FromWaste(int crust, boolean p, boolean pl, boolean gl, boolean ca)
{
    myPlot = 1018.0;
    myCrust = crust;
    myP = p;
    myPl = pl;
    myGl = gl;
    myCa = ca;
}

My issue is that boolean array, trshIt. Since I am putting variables in the array that have not been initialized yet, it gives those variables default values of false. If I put it in the constructor first, then I get an error complaining that the variable trshIt can not be found; pointing to the instance that I am calling that variable. So I have tried different forms of it in different areas and I am like trapped in a maze right now trying to get that array to work properly. I need all the help I can get. Ideas?

  • 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-30T01:45:14+00:00Added an answer on May 30, 2026 at 1:45 am

    Declare trshIt as a member of the class, but initialize it in the constructor, like this:

    boolean [] trshIt;
    double [] CO2TrashEmissions = {184.0, 25.6, 46.6, 165.8};
    
    //constructor
    CO2FromWaste(int crust, boolean p, boolean pl, boolean gl, boolean ca)
    {
        myPlot = 1018.0;
        myCrust = crust;
        myP = p;
        myPl = pl;
        myGl = gl;
        myCa = ca;
    
        trshIt = new boolean[4];
        trshIt[0] = myP;
        trshIt[1] = myPla;
        trshIt[2] = myGl;
        trshIt[3] = myCa;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this same question was asked for Entity Framework 1, but now that
I've asked this same question with Python. Now I like to know if this
This is driving me nuts. I believe I asked this exact same question, but
I asked this question a while back but now I'm looking to implement an
I've asked this question before but couldn't get the answer I was looking for
I originally asked this question on cstheory.stackexchange.com but was suggested to move it to
yes I know, this seems to be the same question as asked thousands of
I asked this question before. But now I am wondering why the following is
I asked this previously but Jeff Atwood moved my question to superuser.com. I need
Initially I asked this Question and written my own plugin to achieve the same,But

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.