SlideShare a Scribd company logo
5
Most read
8
Most read
17
Most read
Operators in JAVA ..
OPERATOR
 An operator is a symbol that operates on one or
more arguments to produce a result.
 Java provides a rich set of operators to
manipulate variables
OPERANDS
 An operands are the values on which the operators act upon.
 An operand can be:
 -> A numeric variable - integer, floating point or character
 -> Any primitive type variable - numeric and boolean
 -> Reference variable to an object
 -> A literal - numeric value, boolean value, or string.
-> An array element, "a[2]“
-> char primitive, which in numeric operations is treated
as an unsigned two byte integer
TYPES OF OPERATORS
 1. Assignment Operators
 2. Increment Decrement Operators
 3. Arithmetic Operators
 4. Bitwise Operators
 5. Relational Operators
 6. Logical Operators
 7. Ternary Operators
 8. Comma Operators
 9. Instanceof Operators
ASSIGNMENT OPERATORS
 The assignment statements has the following syntax :
<variable>=<expression>
 Assigning primitive value
int a, b;
a = 2; // 2 is assigned to variable a
b = 5; // 5 is assigned to variable b
Assigning references
Home home1 = new Home(); //new object created
Home home2 = home1; //assigning the reference of home1 in home2
ASSIGNING VALUES EXAMPLE
INCREMENT AND DECREMENT OPERATORS
++ AND --
 The increment and decrement operators add an integer
variable by one.
 increment operator:
 two successive plus signs, ++
 decrement operator: --
Common Shorthand
a = a + 1; a++; or ++a;
a = a - 1; a--; or --a
EXAMPLE OF ++ AND -- OPERATORS
ARITHMETIC OPERATORS
 The arithmetic operators are used to construct mathematical expressions as
in algebra.
 Their operands are of numeric type.
SIMPLE ARITHMETIC
BITWISE OPERATORS
 Java's bitwise operators operate on individual bits
of integer (int and long) values.
 If an operand is shorter than an int, it is
promoted to int before doing the operations.
BITWISE OPERATORS
EXAMPLE OF BITWISE OPERATORS
EXAMPLE CONT.,
RELATIONAL OPERATORS
 A relational operator compares two values and
determines the relationship between them.
 For example, != returns true if its two operands are
unequal.
 Relational operators are used to test whether two values
are equal, whether one value is greater than another, and
so forth
Operators in java
EXAMPLE OF RELATIONAL OPERATORS
LOGICAL OPERATORS
 These logical operators work only on boolean operands. Their return values
are always boolean.
EXAMPLE OF LOGICAL OPERATORS
TERNARY OPERATORS
 Java has a short hand way by using ?: the ternary aka conditional operator
for doing ifs that compute a value.
 Unlike the if statement, the conditional operator is an expression which can
be used for
COMMA OPERATORS
 Java has an often look past feature within it’s for loop
and this is the comma operator.
 Usually when people think about commas in the java
language they think of a way to split up arguments within
a functions parameters
EXAMPLE OF COMMA OPERATOR
INSTANCEOF OPERATORS
 This operator is used only for object reference variables. The
operator checks whether the object is of a particular type(class type
or interface type).
 InstanceOf operator is wrriten as:
EXAMPLE OF INSTANCEOF OPERATOR
Operators in java

More Related Content

What's hot (20)

PDF
Arrays in Java
Naz Abdalla
 
PPTX
Java Data Types
Spotle.ai
 
PPTX
Java Tokens
Madishetty Prathibha
 
PPSX
Data Types & Variables in JAVA
Ankita Totala
 
PPTX
JAVA AWT
shanmuga rajan
 
PPTX
Data structure and algorithm using java
Narayan Sau
 
PPTX
Methods in java
chauhankapil
 
PPT
Java buzzwords
ramesh517
 
PPTX
Command line arguments
Ashok Raj
 
PPTX
Packages in java
Elizabeth alexander
 
PPTX
Data types in java
HarshitaAshwani
 
PPTX
Type casting in java
Farooq Baloch
 
PPT
Java static keyword
Lovely Professional University
 
PPTX
Constructor and Types of Constructors
Dhrumil Panchal
 
PPTX
INHERITANCE IN JAVA.pptx
NITHISG1
 
PDF
Genesis and Overview of Java
Ravi_Kant_Sahu
 
PPTX
Java package
CS_GDRCST
 
PPTX
Introduction to JAVA
ParminderKundu
 
PPT
Applet life cycle
myrajendra
 
Arrays in Java
Naz Abdalla
 
Java Data Types
Spotle.ai
 
Data Types & Variables in JAVA
Ankita Totala
 
JAVA AWT
shanmuga rajan
 
Data structure and algorithm using java
Narayan Sau
 
Methods in java
chauhankapil
 
Java buzzwords
ramesh517
 
Command line arguments
Ashok Raj
 
Packages in java
Elizabeth alexander
 
Data types in java
HarshitaAshwani
 
Type casting in java
Farooq Baloch
 
Java static keyword
Lovely Professional University
 
Constructor and Types of Constructors
Dhrumil Panchal
 
INHERITANCE IN JAVA.pptx
NITHISG1
 
Genesis and Overview of Java
Ravi_Kant_Sahu
 
Java package
CS_GDRCST
 
Introduction to JAVA
ParminderKundu
 
Applet life cycle
myrajendra
 

Similar to Operators in java (20)

PPTX
Operators in java By cheena
Chëëñå Båbü
 
PPT
Shubhrat operator &amp; expression
Shubhrat Mishra
 
PPTX
operat in vb .pptx
classall
 
PPTX
Lecture-02-JAVA, data type, token, variables.pptx
ChandrashekharSingh859453
 
PPT
Java Operators.ppt
Pragna15
 
PPTX
Python Lec-6 Operatorguijjjjuugggggs.pptx
ks812227
 
PPTX
Operators in c++
ABHIJITPATRA23
 
ODP
operators in c++
Kartik Fulara
 
ODP
operators in c++
Kartik Fulara
 
PPTX
OCA Java SE 8 Exam Chapter 2 Operators & Statements
İbrahim Kürce
 
PPTX
Operators and Expressions in C#
Simplilearn
 
PPTX
Python programming language introduction unit
michaelaaron25322
 
PDF
Operators-WPS Office.pdf
DeekshithSkandaM
 
PDF
Chapter 01 Introduction to Java by Tushar B Kute
Tushar B Kute
 
PPT
4_A1208223655_21789_2_2018_04. Operators.ppt
RithwikRanjan
 
PDF
Types of Operators in C
Thesis Scientist Private Limited
 
PPTX
Operators used in vb.net
Jaya Kumari
 
PPTX
Operators in Python
Anusuya123
 
PPTX
OCA JAVA - 3 Programming with Java Operators
Fernando Gil
 
PPTX
java-tokens-data-types.pptx ciiiidddidifif
sayedshaad02
 
Operators in java By cheena
Chëëñå Båbü
 
Shubhrat operator &amp; expression
Shubhrat Mishra
 
operat in vb .pptx
classall
 
Lecture-02-JAVA, data type, token, variables.pptx
ChandrashekharSingh859453
 
Java Operators.ppt
Pragna15
 
Python Lec-6 Operatorguijjjjuugggggs.pptx
ks812227
 
Operators in c++
ABHIJITPATRA23
 
operators in c++
Kartik Fulara
 
operators in c++
Kartik Fulara
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
İbrahim Kürce
 
Operators and Expressions in C#
Simplilearn
 
Python programming language introduction unit
michaelaaron25322
 
Operators-WPS Office.pdf
DeekshithSkandaM
 
Chapter 01 Introduction to Java by Tushar B Kute
Tushar B Kute
 
4_A1208223655_21789_2_2018_04. Operators.ppt
RithwikRanjan
 
Types of Operators in C
Thesis Scientist Private Limited
 
Operators used in vb.net
Jaya Kumari
 
Operators in Python
Anusuya123
 
OCA JAVA - 3 Programming with Java Operators
Fernando Gil
 
java-tokens-data-types.pptx ciiiidddidifif
sayedshaad02
 
Ad

More from AbhishekMondal42 (20)

PPTX
Oss evaluation-certification-oss-financial-advantages
AbhishekMondal42
 
PPTX
Word press 01
AbhishekMondal42
 
PPTX
Word press posts(preview &amp; publish)
AbhishekMondal42
 
PPTX
Word press posts(add , edit , delete post)
AbhishekMondal42
 
PPTX
Word press pages(edit and delete)
AbhishekMondal42
 
PPTX
Word press pages(add)
AbhishekMondal42
 
PPTX
Word press media(add,insert,delete)
AbhishekMondal42
 
PPTX
Word press media library
AbhishekMondal42
 
PPTX
Word press widget management
AbhishekMondal42
 
PPTX
Word press view plugins
AbhishekMondal42
 
PPTX
Word press user roles
AbhishekMondal42
 
PPTX
Word press theme management
AbhishekMondal42
 
PPTX
Word press personal profile
AbhishekMondal42
 
PPTX
Word press moderate comments
AbhishekMondal42
 
PPTX
Word press install plugins
AbhishekMondal42
 
PPTX
Word press edit users
AbhishekMondal42
 
PPTX
Word press edit tags
AbhishekMondal42
 
PPTX
Word press edit links
AbhishekMondal42
 
PPTX
Word press edit comments
AbhishekMondal42
 
PPTX
Word press delete users
AbhishekMondal42
 
Oss evaluation-certification-oss-financial-advantages
AbhishekMondal42
 
Word press 01
AbhishekMondal42
 
Word press posts(preview &amp; publish)
AbhishekMondal42
 
Word press posts(add , edit , delete post)
AbhishekMondal42
 
Word press pages(edit and delete)
AbhishekMondal42
 
Word press pages(add)
AbhishekMondal42
 
Word press media(add,insert,delete)
AbhishekMondal42
 
Word press media library
AbhishekMondal42
 
Word press widget management
AbhishekMondal42
 
Word press view plugins
AbhishekMondal42
 
Word press user roles
AbhishekMondal42
 
Word press theme management
AbhishekMondal42
 
Word press personal profile
AbhishekMondal42
 
Word press moderate comments
AbhishekMondal42
 
Word press install plugins
AbhishekMondal42
 
Word press edit users
AbhishekMondal42
 
Word press edit tags
AbhishekMondal42
 
Word press edit links
AbhishekMondal42
 
Word press edit comments
AbhishekMondal42
 
Word press delete users
AbhishekMondal42
 
Ad

Recently uploaded (20)

PDF
I3PM Case study smart parking 2025 with uptoIP® and ABP
MIPLM
 
PDF
Cooperative wireless communications 1st Edition Yan Zhang
jsphyftmkb123
 
PPTX
Parsing HTML read and write operations and OS Module.pptx
Ramakrishna Reddy Bijjam
 
PDF
Free eBook ~100 Common English Proverbs (ebook) pdf.pdf
OH TEIK BIN
 
PPTX
Connecting Linear and Angular Quantities in Human Movement.pptx
AngeliqueTolentinoDe
 
PPTX
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
PDF
The Power of Compound Interest (Stanford Initiative for Financial Decision-Ma...
Stanford IFDM
 
PPTX
ENGLISH 8 REVISED K-12 CURRICULUM QUARTER 1 WEEK 1
LeomarrYsraelArzadon
 
PDF
AI-assisted IP-Design lecture from the MIPLM 2025
MIPLM
 
PDF
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
PPTX
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
 
PDF
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
PPTX
Life and Career Skills Lesson 2.pptxProtective and Risk Factors of Late Adole...
ryangabrielcatalon40
 
PPTX
How to Add a Custom Button in Odoo 18 POS Screen
Celine George
 
PDF
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
PPTX
The Gift of the Magi by O Henry-A Story of True Love, Sacrifice, and Selfless...
Beena E S
 
PDF
COM and NET Component Services 1st Edition Juval Löwy
kboqcyuw976
 
PPTX
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
PDF
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
PPTX
Ward Management: Patient Care, Personnel, Equipment, and Environment.pptx
PRADEEP ABOTHU
 
I3PM Case study smart parking 2025 with uptoIP® and ABP
MIPLM
 
Cooperative wireless communications 1st Edition Yan Zhang
jsphyftmkb123
 
Parsing HTML read and write operations and OS Module.pptx
Ramakrishna Reddy Bijjam
 
Free eBook ~100 Common English Proverbs (ebook) pdf.pdf
OH TEIK BIN
 
Connecting Linear and Angular Quantities in Human Movement.pptx
AngeliqueTolentinoDe
 
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
The Power of Compound Interest (Stanford Initiative for Financial Decision-Ma...
Stanford IFDM
 
ENGLISH 8 REVISED K-12 CURRICULUM QUARTER 1 WEEK 1
LeomarrYsraelArzadon
 
AI-assisted IP-Design lecture from the MIPLM 2025
MIPLM
 
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
 
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
Life and Career Skills Lesson 2.pptxProtective and Risk Factors of Late Adole...
ryangabrielcatalon40
 
How to Add a Custom Button in Odoo 18 POS Screen
Celine George
 
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
The Gift of the Magi by O Henry-A Story of True Love, Sacrifice, and Selfless...
Beena E S
 
COM and NET Component Services 1st Edition Juval Löwy
kboqcyuw976
 
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
Ward Management: Patient Care, Personnel, Equipment, and Environment.pptx
PRADEEP ABOTHU
 

Operators in java

  • 2. OPERATOR  An operator is a symbol that operates on one or more arguments to produce a result.  Java provides a rich set of operators to manipulate variables
  • 3. OPERANDS  An operands are the values on which the operators act upon.  An operand can be:  -> A numeric variable - integer, floating point or character  -> Any primitive type variable - numeric and boolean  -> Reference variable to an object  -> A literal - numeric value, boolean value, or string. -> An array element, "a[2]“ -> char primitive, which in numeric operations is treated as an unsigned two byte integer
  • 4. TYPES OF OPERATORS  1. Assignment Operators  2. Increment Decrement Operators  3. Arithmetic Operators  4. Bitwise Operators  5. Relational Operators  6. Logical Operators  7. Ternary Operators  8. Comma Operators  9. Instanceof Operators
  • 5. ASSIGNMENT OPERATORS  The assignment statements has the following syntax : <variable>=<expression>  Assigning primitive value int a, b; a = 2; // 2 is assigned to variable a b = 5; // 5 is assigned to variable b Assigning references Home home1 = new Home(); //new object created Home home2 = home1; //assigning the reference of home1 in home2 ASSIGNING VALUES EXAMPLE
  • 6. INCREMENT AND DECREMENT OPERATORS ++ AND --  The increment and decrement operators add an integer variable by one.  increment operator:  two successive plus signs, ++  decrement operator: -- Common Shorthand a = a + 1; a++; or ++a; a = a - 1; a--; or --a
  • 7. EXAMPLE OF ++ AND -- OPERATORS
  • 8. ARITHMETIC OPERATORS  The arithmetic operators are used to construct mathematical expressions as in algebra.  Their operands are of numeric type.
  • 10. BITWISE OPERATORS  Java's bitwise operators operate on individual bits of integer (int and long) values.  If an operand is shorter than an int, it is promoted to int before doing the operations.
  • 12. EXAMPLE OF BITWISE OPERATORS
  • 14. RELATIONAL OPERATORS  A relational operator compares two values and determines the relationship between them.  For example, != returns true if its two operands are unequal.  Relational operators are used to test whether two values are equal, whether one value is greater than another, and so forth
  • 17. LOGICAL OPERATORS  These logical operators work only on boolean operands. Their return values are always boolean.
  • 18. EXAMPLE OF LOGICAL OPERATORS
  • 19. TERNARY OPERATORS  Java has a short hand way by using ?: the ternary aka conditional operator for doing ifs that compute a value.  Unlike the if statement, the conditional operator is an expression which can be used for
  • 20. COMMA OPERATORS  Java has an often look past feature within it’s for loop and this is the comma operator.  Usually when people think about commas in the java language they think of a way to split up arguments within a functions parameters
  • 21. EXAMPLE OF COMMA OPERATOR
  • 22. INSTANCEOF OPERATORS  This operator is used only for object reference variables. The operator checks whether the object is of a particular type(class type or interface type).  InstanceOf operator is wrriten as: