Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Operator in Java programming language

Posted on September 28, 2017January 24, 2020

Table of Contents

  • The operator in Java programming language
  • Java operators
    • 1. Arithmetic Operator in Java
    • 2. Unary Operator in Java
    • 3. Assignment Operator
    • 4. Relational Operator
    • 5. Logical Operator
    • 6. Bitwise Operator
  • Related

The operator in Java programming language

In this tutorial, we will discuss the concept of Operator in Java programming language

Java operators

Many types of operators are available in java which are used to perform various operations.
Different types of java operators are given below

  1. Arithmetic Operator
  2. Unary Operator
  3. Assignment Operator
  4. Shift Operator
  5. Relational Operator
  6. Bitwise Operator
  7. Logical Operator
  8. Ternary Operator

1. Arithmetic Operator in Java

We can use arithmetic operators to perform the calculation to calculate the value in programs. Arithmetic operators +,-,*,/, and % perform addition,subtraction, multiplication and modulus.
Arithmetic operators can be applied on any numeric type.

Operator in Java programming language
Arithmetic

Example
Operator in Java programming language
Example – arithmetic
When te above code is executed it produces the following result
addition of a+b  :32
subtraction of a-b  :8
multiplication of a*b  :240
division od a/b :1
modulus of a/b :8


2. Unary Operator in Java

Unary operators require only one operand to perform various operations such as increment/ decrement of the value by one.
Operator in Java programming language
Unary
Operator in Java programming language
Unary – Example
When te above code is executed it produces the following result
Value of a++ is :10
Value of a-- is :11
Value of ++a is :11
Value of --a is :10

3. Assignment Operator

The assignment operator is used to assign a value to the variable. We simply understand and assign the value on the right of the ‘Assignment operator‘ to the variable on the left.

Operator in Java programming language
Assignment

Example

Operator in Java programming language
Assignment Example
When the above code is executed, it produces the following result
Value of a+=6 is  :16
Value of a-=5 is   :11
Value of a*=4 is  :44
Value of a/=3 is   :14
Value of a%=2 is   :0


4. Relational Operator

Java has six relational operators that compare two numbers and return only boolean value. Relational operators are <,>,==,<=,>= and != in Java.

 

Operator in Java programming language
Relational
Operator in Java programming language
Relational – Example
When te above code is executed it produces the following result
 The result of a==b = false
 The result of a!=b = true
 The result of a>b = false
 The result of a<b = true
 The result of a>=b = false
 The result of a<=b = true


5. Logical Operator

The logical operator is used to compare multiple conditions and return the boolean value.

Operator in Java programming language
Logical
Operator in Java programming language
Example –

 

When te above code is executed it produces the following result
false
true
true
false
false
false
true


6. Bitwise Operator

Bitwise Operator in Java
Operator in Java programming language
Bitwise
Similar post
Operator in C++
Operator in C
Operator in Python

Related

Recent Posts

  • Multiply two numbers in Java using scanner| 5 different ways
  • 5 different ways to Divide two numbers in Java using scanner
  • Learn 8 Ways to Subtract Two Numbers Using Methods in Java
  • 10 ways to subtract two numbers in Java
  • Java Code Examples – Multiply Two Numbers in 5 Easy Ways
  • How to Divide two numbers in Java| 5 different ways

tag

Addition (8) Array (38) C++ language (91) C language (98) c sharp (23) Division (8) Function (29) if else (32) Java language (108) JavaScript (5) loops (138) Multiply (8) Oop (2) patterns (66) PHP (13) Python Language (38) Subtraction (9) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2026 Code for Java c | Powered by SuperbThemes