Understanding Operators In Java

Subscribe to my newsletter and never miss my upcoming articles

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.

Arithmetic Operators:

These operators are used for mathematical operations in our code. There are different types of arithmetic operators, which goes as:

  1. "+" -> Adds two operands
  2. "-" -> Subtracts second operand from the first
  3. "*" -> Multiplies two operands
  4. "/" -> Divides numerator by denominator
  5. "%" -> Calculates remainder of division

Relational Operators:

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.

  1. "==" -> To check if two operands are equal
  2. "!=" -> To check if two operands are not equal
  3. ">" -> Check if operand on the left is greater than operand on the right
  4. "<" -> Check if operand on the left is smaller than operand on the right
  5. ">=" -> Check if left operand is greater than or equal to operand on the right
  6. "<=" -> Check if left operand is smaller than or equal to operand on the right

Next and the last one is Logical Operators.

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:

  1. "&&" -> Logical AND
  2. "||" -> Logical OR
  3. "!" -> Logical NOT

So, this was all about operators in Java. I'll see you in my next blog next Friday.

Tags:#java

No Comments Yet