What does this line mean in Java: boolean retry = id == 1;
id == 1
is a boolean expression which is true if id
equals 1
, and false otherwise.
boolean retry = id == 1;
declares a boolean variable named retry
, and assigns the value of the boolean expression id == 1
to this variable.
So it declares a boolean variable which is true if id == 1
, and false otherwise.
To make it a bit clearer, you might write it that way:
boolean retry = (id == 1);
retry
is true
if id
has the value 1, otherwise retry
is false
.