Operators are operations on variables and values. In this chapter, We will talk about operators in Java, There are many types of operators that we will discuss one by one in this chapter.
In the example below, we use the + operator to add together two numbers:
int x = 10 + 10; //20
Java operators
- Arithmetic operators
- Assignment operators
- Comparison operators
- Logical operators
- Bitwise operators
Arithmetic Operators
Operator | Name |
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
% | Modulus |
++ | Increment |
-- | Decrement |
Java Assignment Operators
assignment operator (=) to assign the any value
example:
int x = 20;
Java Comparison Operators
used to compare values:
Operator | Name |
== | Equal to |
!= | Not equal to |
> | Greater than |
< | Less than |
>= | Greater than or equal to |
<= | Less than or equal to |
Java Logical Operators
used to determine the logic between variables or values
Operator | Name |
&& | Logical and |
|| | Logical or |
! | Logical not |
in our further chapters we will use these operators so just remember it.
Thanks, few Java operators were discussed if you like this chapter please give a thumbs up.