java tutorial - Java Math Operators - java programming - learn java - java basics - java for beginners
Learn java - java tutorial - Java Math Operators - java examples - java programs
Assignment Operator:
- Assignment operators are used in Java to assign values to variables.
- The assignment operator assigns the value on its right to the variable on its left. Here, 5 is assigned to the variable age using = operator.
Arithmetic Operators :
- Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication etc
Operator | Meaning |
---|---|
+ | Addition (also used for string concatenation) |
- | Subtraction Operator |
* | Multiplication Operator |
/ | Division Operator |
% | Remainder Operator |
Unary Operators :
- An equality and a relational operator determines the relationship among two operands. It checks if an operand is greater than, less than, equal to, not equal to and so on. Depending on the relationship, it results to either
true
orfalse.
Logical Operators :
- The logical operators conditional-OR (||) and conditional-AND (&&) operates on boolean expressions.
Ternary Operator :
- The conditional operator or ternary operator (?:) is shorthand for if-then-else statement. The syntax of conditional operator is shorthand for
if-then-else
statement. The syntax of conditional operator is
Syntax:
Bitwise and Bit Shift Operators
- To perform bitwise and bit shift operators in Java, these operators are used.
Operator | Description |
---|---|
~ | Bitwise Complement |
<< | Left Shift |
>> | Right Shift |
>>> | Unsigned Right Shift |
& | Bitwise AND |
^ | Bitwise exclusive OR |
| | Bitwise inclusive OR |
- These operators are not commonly used. Visit this page to learn more about bitwise and bit shift operators.