& Operator in Java with Examples Last Updated : 10 Oct, 2019 Comments Improve Suggest changes Like Article Like Report The & operator in Java has two definite functions: As a Relational Operator: & is used as a relational operator to check a conditional statement just like && operator. Both even give the same result, i.e. true if all conditions are true, false if any one condition is false. However, there is a slight difference between them, which highlights the functionality of & operator: && operator: It only evaluates the next condition, if the condition before it is true. If anyone condition is false, it does not evaluate the statement any further. & operator: It evaluates all conditions even if they are false. Thus, any change in the data values due to the conditions will only be reflected in this case. Example: Java // Java program to demonstrate // & operator as relational operator import java.io.*; class GFG { public static void main(String[] args) { int x = 5, y = 7, z = 9; System.out.println("Demonstrating && operator"); if ((x > y) && (x++ > z)) ; else System.out.println("Value of x: " + x); System.out.println("\nDemonstrating & operator"); if ((x > y) & (x++ > z)) ; else System.out.println("Value of x: " + x); } } Output: Demonstrating && operator Value of x: 5 Demonstrating & operator Value of x: 6 As a Bitwise AND: & operator is used for adding Bitwise numbers in Java. Bitwise numbers are binary numbers stored in the form of integers. Some people will ask what is the use of these Bitwise numbers anyway? Why not store every number in its decimal form and perform the normal operations using our traditional operators: +, -, /, %, *. Its because all our encoding and decoding of data is done in bits, as they allow packing a huge amount of information into a tiny space. Example: Java // Java program to demonstrate // & operator as bitwise operator import java.io.*; class GFG { public static void main(String[] args) { int a = 12; int b = 25; System.out.println("Demonstrating & operator\n"); int c = a & b; System.out.println(a + " & " + b + " = " + c); } } Output: Demonstrating & operator 12 & 25 = 8 Comment More infoAdvertise with us Next Article & Operator in Java with Examples D daksheshgusain2001 Follow Improve Article Tags : Java Java-Operators Practice Tags : JavaJava-Operators Similar Reads && operator in Java with Examples && is a type of Logical Operator and is read as "AND AND" or "Logical AND". This operator is used to perform "logical AND" operation, i.e. the function similar to AND gate in digital electronics. One thing to keep in mind is the second condition is not evaluated if the first one is false, i. 1 min read Java Arithmetic Operators with Examples Operators constitute the basic building block to any programming language. Java too provides many types of operators which can be used according to the need to perform various calculations and functions, be it logical, arithmetic, relational, etc. They are classified based on the functionality they 6 min read Java Assignment Operators with Examples Operators constitute the basic building block of any programming language. Java too provides many types of operators which can be used according to the need to perform various calculations and functions, be it logical, arithmetic, relational, etc. They are classified based on the functionality they 7 min read Java Unary Operator with Examples Operators constitute the basic building block to any programming language. Java too provides many types of operators which can be used according to the need to perform various calculations and functions be it logical, arithmetic, relational, etc. They are classified based on the functionality they p 8 min read Java Logical Operators with Examples Logical operators are used to perform logical "AND", "OR", and "NOT" operations, i.e., the functions similar to AND gate and OR gate in digital electronics. They are used to combine two or more conditions/constraints or to complement the evaluation of the original condition under particular consider 8 min read Like