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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:57:40+00:00 2026-06-03T14:57:40+00:00

Goodday everybody, So I made a class Temperature, which has a constructor to make

  • 0

Goodday everybody,

So I made a class Temperature, which has a constructor to make the temperature.
Temperature is an arraylist of 2 numbers [coldness, hotness].

    public int hotness;
public int coldness;
public int[] temperature;
public int maxTemperature = 10000;


//Constructor Temperature
public Temperature(int hotness, int coldness) {
    /**
     * A constructor for the Array Temperature
     */
    maxTemperature = getMaxTemperature();
        if(hotness <= maxTemperature && coldness <= maxTemperature)
        temperature[0] = coldness;
        temperature[1] = hotness;
        }

and now I want to go into another class and use that object Temperature to do some calculations. Here is the code for it.

    //Variabels

public int volatility;
private static Temperature temperature;
private static int intrensicExplosivity;

    public static int standardVolatility(){
    if(temperature[0] == 0){
        int standardVolatility = 100 * intrensicExplosivity * (0.10 * temperature[1]);
    }

so now I get the error: The type of the expression must be an array type but it resolved to “Temperature”

any solutions?

I’m quite new to Java, so it’s probably just some synthax errors, but I just can’t find it.

thanks in advance.
David

  • 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-03T14:57:42+00:00Added an answer on June 3, 2026 at 2:57 pm

    Instead of

    public static int standardVolatility() {
        if(temperature[0] == 0) {
    

    try

    public static int standardVolatility() {
        if(tepmerature.temperature[0] == 0) {
           ^^^^^^^^^^^^
    

    Note that the temperature in your second snippet is of type Temperature which itself has an int-array called temperature. To access the temperature-array of the Temperature object, you’ll have to do temperature.temperature.


    As @Marko Topolnik points out, you may also want to change

    public int[] temperature;
    

    to

    public int[] temperature = new int[2];
    

    in order to make room for the two temperature values.

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

Sidebar

Related Questions

Good day. I got an HTML page which is small and has no scroll
Goodday everybody, My problem is the following: I am communicating with serialport to a
Good Day All we are trying to do is inside a trigger make sure
Good day, I have a gen_server process which does some long-running state-updating tasks periodically
Good day I have a basic toolbar to which I added ImageIcon buttons. The
Good day everybody! Having the following code: template<typename T, typename OutStream = std::ostream> struct
Good day everybody. I've doing a bit of training at working with Flex and
Good day everybody, I'm having troubles with the display of a data that does
Goodday I can't seem to use my dataset in a Null comparison I'm trying
Good day! I know there has been lots of posts for this kind of

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.