I encountered the code example below in the JavaNotes book. The answer was that after execution the x is equal to 2.
My question is how exactly does this work?
I see it is not an if-else flow, but in the second "if" the boolean expression is false, so X shall not obtain value 2. How is this happening?
int x;
x = -1;
if (x < 0)
x = 1;
if (x >= 0)
x = 2;
Aucun commentaire:
Enregistrer un commentaire