Why does my boolean test in java always fail?

后端 未结 6 1408
别跟我提以往
别跟我提以往 2021-01-21 21:59

I am trying to make a boolean test so that if one of the tire pressures is below 35 or over 45 the system outputs \"bad inflation\".

In my class I must use a boolean, wh

6条回答
  •  太阳男子
    2021-01-21 22:38

    Your problem is that there is only a single = sign in the expression if (goodPressure = true). That assigns true to goodPressure and then checks to see if goodPressure is still true.

    You need to use a == or a .equals()

提交回复
热议问题