Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Operators used in java programming

Rating
-
Sold
-
Pages
8
Uploaded on
14-10-2024
Written in
2024/2025

Java programming Operators

Institution
Course

Content preview

6/4/2021 Java - Basic Operators - Tutorialspoint




Java - Basic Operators



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
Bitwise Operators
Logical Operators
Assignment Operators
Misc 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 −
Show Examples

Operator Description Example

Adds values on either side of the
+ (Addition) A + B will give 30
operator.

Subtracts right-hand operand from
- (Subtraction) A - B will give -10
left-hand operand.

Multiplies values on either side of the
* (Multiplication) A * B will give 200
operator.

Divides left-hand operand by right-
/ (Division) B / A will give 2
hand operand.

Divides left-hand operand by right-
% (Modulus) B % A will give 0
hand operand and returns remainder.

++ (Increment) Increases the value of operand by 1. B++ gives 21

-- (Decrement) Decreases the value of operand by 1. B-- gives 19


https://www.tutorialspoint.com/java/java_basic_operators.htm 1/8

, 6/4/2021 Java - Basic Operators - Tutorialspoint

The Relational Operators
There are following relational operators supported by Java language.
Assume variable A holds 10 and variable B holds 20, then −
Show Examples

Operator Description Example

Checks if the values of two operands are
== (equal to) equal or not, if yes then condition becomes (A == B) is not true.
true.

Checks if the values of two operands are
!= (not equal to) equal or not, if values are not equal then (A != B) is true.
condition becomes true.

Checks if the value of left operand is greater
> (greater than) than the value of right operand, if yes then (A > B) is not true.
condition becomes true.

Checks if the value of left operand is less
< (less than) than the value of right operand, if yes then (A < B) is true.
condition becomes true.

Checks if the value of left operand is greater
>= (greater than or
than or equal to the value of right operand, if (A >= B) is not true.
equal to)
yes then condition becomes true.

Checks if the value of left operand is less
<= (less than or
than or equal to the value of right operand, if (A <= B) is true.
equal to)
yes then condition becomes true.


The Bitwise Operators

Java defines several bitwise operators, which can be applied to the integer types, long, int, short,
char, and byte.
Bitwise operator works on bits and performs bit-by-bit operation. Assume if a = 60 and b = 13; now
in binary format they will be as follows −
a = 0011 1100

b = 0000 1101
-----------------

a&b = 0000 1100

https://www.tutorialspoint.com/java/java_basic_operators.htm 2/8

Written for

Institution
Course

Document information

Uploaded on
October 14, 2024
Number of pages
8
Written in
2024/2025
Type
Class notes
Professor(s)
Unknown
Contains
All classes

Subjects

$6.79
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
khushisharma8

Get to know the seller

Seller avatar
khushisharma8 Govt. Polytechnic hamirpur
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
6
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions