Mega Code Archive

 
Categories / Java Tutorial / Operators
 

&& versus &

Conditional && will not evaluate the right-hand operand if the left-hand operand is false. public class MainClass {   public static void main(String[] arg) {     int value = 8;     int count = 10;     int limit = 11;     if (++value % 2 == 0 & ++count < limit) {       System.out.println("here");       System.out.println(value);       System.out.println(count);     }     System.out.println("there");     System.out.println(value);     System.out.println(count);   } } there 9 11