What is difference between '& ' and '&&' operators in java?

& is bitwise. && is logical. & evaluates both sides of the operation. && evaluates the left side of the operation; if it's true, it continues and evaluates the right side.

If we use '&' operator, JVM checks both conditions whether the first condition is true or false. & is a bitwise operator and compares each operand bitwise.

if we use '&&' operator then JVM  checks the first condition and if it is false then, it is not going to check 2nd condition and if the first condition is true then checks 2nd condition.

package test.myjava;

public class Operators 
{
    public static void main(String args[])
    {
        int a = 60, b = 13;

        System.out.println(a & b);

        if(a > 20 && b > 20)   //One conditions is true
        {
            System.out.println("Not Executed");
        }
		
        if(a > 20 && b > 10) . //both conditions are true
        {
             System.out.println("Executed");
        }
    }
}

Output

12 which is 0000 0010

Executed