An operator, in Java, is a special symbols performing specific operations on one, two or three operands and then returning a result. The operators are classified and listed according to precedence order. Java operators are generally used to manipulate primitive data types. The Java operators are classified into eight different categories: assignment, arithmetic, relational, logical, bitwise, compound assignment, conditional and type comparison operators.
Assignment operators: Assign the value on its right to the operand on its left. It is denoted by the symbol “=”. The assignment operator statement has the syntax as shown below:
int distance = 0
int radius = 2
Arithmetic operators: There are eight arithmetic operators available in Java. They perform addition, subtraction, multiplication, division, modulo (or remainder), increment (or add 1), decrement (or subtract 1), and negation.
+ Additive operator (also used for String concatenation)
* Multiplication operator
/ Division operator
% remainder operator
Relational Operators: The relational operators are used to compare 2 or more objects. There are six relational operators in Java:
== equal to
!= not equal to
>> greater than
>= greater than or equal to
< less than
<= less than or equal to
Logical operators: The logical operators return a true or false value according to the state of the variables. Java provides six logical operators: AND, OR, Conditional OR, exclusive OR, and NOT.
Bitwise operators: Manipulate the contents of variables at the bit level. The data type of these variables must be numeric (char, int, long, short). There are seven bitwise operators. They are AND, OR, Exclusive-OR, compliment, Left-shift, Signed Right-Shift, and Unsigned Right-shift.
Compound operators: Are used when shortcuts need to be performed in programming operations. There are eleven compound assignment operators in java. The syntax for compound operators is:
argument 1 operator = argument2.
Conditional operators: The conditional operator is the only operator that takes three arguments in Java. The conditional operator is equivalent to if-else statement. The operators are:
&& conditional- AND
The operator first assesses the first argument and if that is true, it assesses the next argument. If the first becomes false, then the control moves to the third argument.
Type comparison operators: The instanceof operator compares an object to a specified type. This operator can be used to test if an object is an instance of a class, subclass or a particular interface.
This definition was written in the context of Java