2.8.6.Involve calculation in the short-circuit logical operators
public class MainClass { public static void main(String[] argv) { int val = 0; boolean test = (val == 0) || (++val == 2);
System.out.println("test = " + test + "\nval = " + val);
}
}
test = true
val = 0
public class MainClass { public static void main(String[] argv) { int val = (int) (2 * Math.random()); boolean test = (val == 0) | (++val == 2);
System.out.println("test = " + test + "\nval = " + val);
}
}