Tuesday , June 15 2021
Home / Java / JAVA #06 – Operators in Java

JAVA #06 – Operators in Java

 

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

  • Arithmetic Operators
  • Relational Operators
  • Logical Operators
  • Assignment Operators
  • Increment/Decrement Operators

 

 

  • The Arithmetic Operators:

Arithmetic operators are used in mathematical expressions in the same way that they are used in algebra. The following table lists the arithmetic operators:

Assume integer variable A holds 10 and variable B holds 20, then:

SR.NO Operator and Example
1 + ( Addition )

Adds values on either side of the operator

Example: A + B will give 30

2 – ( Subtraction )

Subtracts right hand operand from left hand operand

Example: A – B will give -10

3 * ( Multiplication )

Multiplies values on either side of the operator

Example: A * B will give 200

4 / (Division)

Divides left hand operand by right hand operand

Example: B / A will give 2

5 % (Modulus)

Divides left hand operand by right hand operand and returns remainder

Example: B % A will give 0

6 ++ (Increment)

Increases the value of operand by 1

Example: B++ gives 21

7 — ( Decrement )

Decreases the value of operand by 1

Example: B– gives 19

 

About Faheem

An adaptable and responsible Software Engineer, who enjoys working with computers and the opportunity to learn new skills and work with new technologies is particularly attractive to me.

Check Also

JAVA #32 – Java application using SQL server (Part: 01)

  In this part we made the GUI front end of a Application.

Leave a Reply

Your email address will not be published.