Types of Operators in Java (Here’s an easy explanation)

What are the operators in java?
What are the operators in java?

Operator Types in Java – Before discussing the logical operators in java, let’s talk about what java is. Java is a computer programming language that is generally used for the development of a system on the back – end. The basic material for beginners that need to be learned in Java is how to create a database, syntaxes in Java, and the functions of each of these syntaxes. That way you will have no trouble while programming with this language.

Well, above is a brief discussion about Java. Now we will go to the earlier discussion, which is about Logical Operators in Java. What are Logical Operators? Logical operators in Java are operators that are generally used to combine several comparison operator conditions in if-else instructions. There are many types of perators in Java, for more details, please see below.

Types of Operators in Java

1. Arithmetic Operators

This operator is used to calculate arithmetic operations

  • + for addition operation
  • – for subtraction operation
  • * for multiplication operations
  • / for division operation
  • % for remainder for

The following is an example of program code in which there is addition arithmetic

Addition arithmetic example
Addition arithmetic example

Why is it called Addition Arithmetic? because pay attention to System.out.print at the bottom, on that line there is a + operator which means adding up the number 1 and number 2.

2. Comparison Operators

What are Comparison Operators? As the name implies, the task of this operator is to compare. The value generated in this operator is a boolean that is between “true” and “false”.

  • > for larger operations
  • < for smaller operations
  • == for operation equal to
  • != for operation not equal to
  • >= for operations greater than equal to
  • <= for smaller operations equal to
example of comparison operation
example of comparison operation

3. Assignment Operators

Assignment operations are used to assign assignments to certain variables which are generally used for assigning values.

  • = for value filling operation
  • += for filling and addition operations
  • -= for fill and subtraction operations
  • *= for filling and multiplication operations
  • /= for filling and dividing operations
  • %= for filling operation and remainder for
Example of assignment operation
Example of assignment operation

3. Logical Operators

  • && for logic AND
  • || for logic OR
  • ! for negation

Logical Operators are used to perform logical operations as in mathematical logic

Example of application of logic AND:

  • Statement 1: My method is a blog site
  • Statement 2: My method is using wordpress

If asked, is my method is a blog site that uses wordpress?

  • Statement 1: My method is blog site = true.
  • Statement 2: My method uses wordpress = true.

What is my method blog site and using wordpress?

statement 1 && statement 2 = true

4. Bitwise Operators

Usually used in binary operations. This operator will count bit-to-bit. When we will add up the variables a and b, then we define the variable and fill in its value with an integer, then this operator will convert the number to binary first and then add it up. The resulting value is a binary number for AND, OR, XOR, and NOT operations.

5. Ternary Operators

Ternary operator is used when creating queries

For example when there is a question: Is this appropriate? Yes No;

Example of ternary operator
Example of ternary operator

When the answerer answers the question correctly, the result that will appear is true, but if the answerer answers the question incorrectly, the result displayed is false.

So that’s a glimpse of Operators in Java, hopefully it can be easily understood. That’s all the information we can provide, we apologize if there are word mistakes. Happy learning friends.