class BoolArray {
boolean [] b = new boolean[3];
int count = 0;
void set(int i)
{
b[i] = true;
++count;
}
public static void main(String [] args)
{
BoolArray ba = new BoolArray();
ba.set(0);
ba.set(2);
ba.test();
}
void test()
{
if ( b[0] && b[1] | b[2] )
count++;
if ( b[1] && b[(++count - 2)] )
count += 7;
System.out.println("count = " + count);
}
}
in all these scenarios,
if ( b[0] && b[1] | b[2] )
if ( b[1] && b[0] || b[2] )
if ( b[1] && b[0] || b[2] )
Why the short circuit logic of '&&' not working as the code is reaching inside the if block?
Please explain also in what order logical operators are executed.