jeudi 13 mai 2021

Do if statements execute in order java [closed]

this is probably a simple problem I'm a complete beginner. Basically I do something with a variable and then change it to 0 but its giving me problems and I'm not sure why.

if (longer>longest){
longest = longer;
longer = 0;
} 

this is the part that's giving me issues. When I deleted "longer = 0" it stopped saying that there was an infinite loop, but it doesn't give the right answer. I want "longer" to reset to 0 after assigning "longest" to its value.

Aucun commentaire:

Enregistrer un commentaire