Java provides operators in the following categories:
-
Arithmetic Operators
-
Bitwise Operators
-
Relational Operator
-
Logical Operator
JAVA also defines some additional operators that handle some special situations.
Arithmetic Operators
Arithmetic operators are used in mathematical operations and similarly in algebra. These are the Arithmetic Operators:
The operands of the arithmetic operators must be of type numeric. You cannot use them in boolean types but can use them in char types.
Bitwise Operators
JAVA programming language also provides operators that perform bitwise and bit shift operations on integral types. The operators discussed in this section are less commonly used. Therefore, their coverage is brief. The intent is to simply make you aware that these operators exist.
Relational Operator
Relational Operators determine if one operand is greater than, less than, equal to, or not equal to another operand. The majority of these operators will probably look familiar to you. Keep in mind that you must use “==”, not “=”, when testing if two primitive values are equal.
Logical Operator
Logical operators are mainly used to control program flow. Usually, you will find them as a part of an if, a while, or some other control statement.
hello. could you tell me please what is the difference between “=” and “==” ?
LikeLiked by 1 person
Hello 🙂 ,
1).
” = ” is assignment operator used to assign value to any datatype
for Example:
int a; // here a is integer variable
a = 5; // so here using ” = ” 5 is assigned to variable a
2).
Now ” == ” is used to compare two values whether they are equal or not
for Example:
int a=5, b=6;
if ( a == b ) // here we can not use ” = “, doing this it will assign value of b to a
{
System.out.println(“a and b are equal”);
}
else
{
System.out.println(“a and b are not equal”);
}
Output : a and b are not equal
LikeLike
nice explain
LikeLike