Java level calculator if statement returning the wrong value (Newbie)

后端 未结 6 1510
野的像风
野的像风 2021-01-21 09:48

i\'m learning some Java and decided to do something simple but it keeps returning the wrong value... i don\'t know why i\'m sure there something that my untrained eye isn\'t pic

6条回答
  •  野性不改
    2021-01-21 10:19

    The out put is 2 because it checks the first if statement which turns out to be false. Then it moves to the if else where it is true as userxp is in fact >=level1xp so userlevel is set to 2 and printed. So as far as I can understand the codes objective, replace the ||(OR) with &&(AND)

提交回复
热议问题