Java operators are used to perform some operations between operands.
int a = 2 , b = 3;
System.out.println(a+b);OUTPUT:
5
Below are the different types of operators
Assignment operator are used to assign value to a variable. = (equal) symbol is use as an assignment operator.
In the below code value 3 is assigned to a with the assignment operator.
int a = 3;
It uses to compare two operands.
Bitwise operators are used to perform operation on bits of a number. This can be applied to the integer types, long, int, short, char, and byte. We have four types of bitwise operations:
Bitwise operator can be easily understood by below table:
Example:
What will the output for bitwise operation of (5 & 9)
Bitwise operator can be easily understood by below table:
Example:
What will the output for bitwise operation of (5 | 9)
Bitwise operator can be easily understood by below table:
Example:
What will the output for bitwise operation of (5 ^ 9)
Bitwise operator can be easily understood by below table:
Example:
What will the output for bitwise operation of (~5)
Note: Compiler gives 2’s complement of number. 2’s compliment of 10 is -6.
Logical operator also called as a Boolean operator as it returns true or false after comparison.
Specialist Master (Architect) with a passion for cutting-edge technologies like AEM (Adobe Experience Manager) and a proven track record of delivering high-quality software solutions.
📝 Blogs
javadoubts.com © All rights reserved