Operators In Java
It's Friday, and here I am with one more new blog. This time again, it's about something related to Java. This blog is about operators in Java, and it is a short one. Operators are used to performing various operations on variables and values. There are different types of operators in Java. Let's go through them one by one.
These operators are used for mathematical operations in our code. There are different types of arithmetic operators, which goes as:
- "+" -> Adds two operands
- "-" -> Subtracts second operand from the first
- "*" -> Multiplies two operands
- "/" -> Divides numerator by denominator
- "%" -> Calculates remainder of division
Relational operators are the operators used to test some kind of relation between two entities. The following table lists the relation operators supported by Java.
- "==" -> To check if two operands are equal
- "!=" -> To check if two operands are not equal
- ">" -> Check if operand on the left is greater than operand on the right
- "<" -> Check if operand on the left is smaller than operand on the right
- ">=" -> Check if left operand is greater than or equal to operand on the right
- "<=" -> Check if left operand is smaller than or equal to operand on the right
Next and the last one is Logical Operators.
Logical operators are mainly used for Boolean operations and the result is also a Boolean i.e. True or False.
Java has basically three logical operators which goes as:
- "&&" -> Logical AND
- "||" -> Logical OR
- "!" -> Logical NOT
So, this was all about operators in Java. I'll see you in my next blog next Friday.