SlideShare a Scribd company logo
OPERATORS IN JAVA
OPERATOR IN JAVA IS A SYMBOL THAT IS USED TO PERFORM
OPERATIONS. FOR EXAMPLE: +, -, *, / ETC.
http://www.javatraininginjaipur.online/
• THERE ARE MANY TYPES OF OPERATORS IN JAVA WHICH ARE GIVEN BELOW:
• UNARY OPERATOR,
• ARITHMETIC OPERATOR,
• SHIFT OPERATOR,
• RELATIONAL OPERATOR,
• BITWISE OPERATOR,
• LOGICAL OPERATOR,
• TERNARY OPERATOR AND
• ASSIGNMENT OPERATOR.
• JAVA OPERATOR PRECEDENCE
http://www.javatraininginjaipur.online/
• JAVA UNARY OPERATOR EXAMPLE: ++ AND —
class OperatorExample{ public static void main(String args[]){ int x=10;
System.out.println(x++);//10 (11) System.out.println(++x);//12 System.out.println(x--
);//12 (11) System.out.println(--x);//10 }}
Output:
10
12
12
10
http://www.javatraininginjaipur.online/
• JAVA UNARY OPERATOR EXAMPLE 2: ++ AND —
class OperatorExample{ public static void main(String args[]){ int a=10; int
b=10; System.out.println(a++ + ++a);//10+12=22 System.out.println(b++ +
b++);//10+11=21 }}
Output:
22
21
Java Unary Operator Example: ~ and !
http://www.javatraininginjaipur.online/
• JAVA UNARY OPERATOR EXAMPLE: ~ AND !
class OperatorExample{
public static void main(String args[]){
int a=10;
int b=-0;
boolean c=true;
boolean d=false;
System.out.println(~a);//-11 (minus of total positive value which starts from 0)
System.out.println(~b);//9 (positive of total minus, positive starts from 0)
System.out.println(!c);//false (opposite of boolean value)
System.out.println(!d);//true
}}
Output:
-11
9
false
true
http://www.javatraininginjaipur.online/
Java Arithmetic Operator Example
class OperatorExample{
public static void main(String args[]){
int a=10;
int b=5;
System.out.println(a+b);//15
System.out.println(a-b);//5
System.out.println(a*b);//50
System.out.println(a/b);//2
System.out.println(a%b);//0
}}
Output::
15
5
50
2
0
http://www.javatraininginjaipur.online/

More Related Content

PDF
Operators in java
PPTX
Operators in java
PPTX
OCA JAVA - 3 Programming with Java Operators
PPTX
Operators In Java Part - 8
PDF
itft-Operators in java
PDF
Java basic operators
PPTX
Operators in java presentation
PPTX
Logical and Conditional Operator In C language
Operators in java
Operators in java
OCA JAVA - 3 Programming with Java Operators
Operators In Java Part - 8
itft-Operators in java
Java basic operators
Operators in java presentation
Logical and Conditional Operator In C language

What's hot (20)

PDF
Conditional operators
 
PPTX
Operator.ppt
PPT
Java operators
PPT
Operators and Expressions in C++
PDF
Operators in c programming
PPTX
Expression and Operartor In C Programming
PPT
PPT
CBSE Class XI :- Operators in C++
PDF
Operators in python
PPTX
Operators and expressions
PPT
Operator & Expression in c++
PPTX
Operators and expressions in c language
PPTX
Operators in C Programming
PPT
C Prog. - Operators and Expressions
PPTX
Operators in java
PPTX
C OPERATOR
PPT
C operator and expression
PPT
Types of operators in C
PPTX
05 operators
PPT
Expressions in c++
Conditional operators
 
Operator.ppt
Java operators
Operators and Expressions in C++
Operators in c programming
Expression and Operartor In C Programming
CBSE Class XI :- Operators in C++
Operators in python
Operators and expressions
Operator & Expression in c++
Operators and expressions in c language
Operators in C Programming
C Prog. - Operators and Expressions
Operators in java
C OPERATOR
C operator and expression
Types of operators in C
05 operators
Expressions in c++
Ad

Similar to Operators in Java (20)

PPTX
Belfast JUG 23-10-2013
PDF
2015 Java update and roadmap, JUG sevilla
PPTX
Hadoop cluster performance profiler
PPTX
Thinking Beyond ORM in JPA
PPTX
Functional Programming With Lambdas and Streams in JDK8
PPTX
Programming in java basics
PPTX
Apache Flink Hands On
PPTX
JDK8 Streams
PPTX
PDF
Java Magazine : The JAVA Virtual Machine alternative languages
PPTX
Core Java introduction | Basics | free course
PDF
OGSA-DAI DQP: A Developer's View
PDF
yelding-the-flow-presentation-2016-year-
PDF
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
PDF
Lambdas And Streams in JDK8
PDF
PDF
WebNet Conference 2012 - Designing complex applications using html5 and knock...
PPTX
Deep Dive into Apache Apex App Development
PPT
Java withrealworldtechnology
KEY
How and why i roll my own node.js framework
Belfast JUG 23-10-2013
2015 Java update and roadmap, JUG sevilla
Hadoop cluster performance profiler
Thinking Beyond ORM in JPA
Functional Programming With Lambdas and Streams in JDK8
Programming in java basics
Apache Flink Hands On
JDK8 Streams
Java Magazine : The JAVA Virtual Machine alternative languages
Core Java introduction | Basics | free course
OGSA-DAI DQP: A Developer's View
yelding-the-flow-presentation-2016-year-
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas And Streams in JDK8
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Deep Dive into Apache Apex App Development
Java withrealworldtechnology
How and why i roll my own node.js framework
Ad

More from Rhythm Suiwal (6)

PPTX
Java do-while Loop
PPTX
JAVA SWITCH STATEMENT
PPTX
HOW TO SET PATH IN JAVA
PPTX
HELLO JAVA PROGRAM
PPTX
FEATURES OF JAVA
PPTX
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
Java do-while Loop
JAVA SWITCH STATEMENT
HOW TO SET PATH IN JAVA
HELLO JAVA PROGRAM
FEATURES OF JAVA
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...

Recently uploaded (20)

PPTX
Institutional Correction lecture only . . .
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Sports Quiz easy sports quiz sports quiz
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Basic Mud Logging Guide for educational purpose
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Cell Types and Its function , kingdom of life
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
Institutional Correction lecture only . . .
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Sports Quiz easy sports quiz sports quiz
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
GDM (1) (1).pptx small presentation for students
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
STATICS OF THE RIGID BODIES Hibbelers.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
O7-L3 Supply Chain Operations - ICLT Program
Abdominal Access Techniques with Prof. Dr. R K Mishra
Final Presentation General Medicine 03-08-2024.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Basic Mud Logging Guide for educational purpose
VCE English Exam - Section C Student Revision Booklet
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Cell Types and Its function , kingdom of life
human mycosis Human fungal infections are called human mycosis..pptx

Operators in Java

  • 1. OPERATORS IN JAVA OPERATOR IN JAVA IS A SYMBOL THAT IS USED TO PERFORM OPERATIONS. FOR EXAMPLE: +, -, *, / ETC. http://www.javatraininginjaipur.online/
  • 2. • THERE ARE MANY TYPES OF OPERATORS IN JAVA WHICH ARE GIVEN BELOW: • UNARY OPERATOR, • ARITHMETIC OPERATOR, • SHIFT OPERATOR, • RELATIONAL OPERATOR, • BITWISE OPERATOR, • LOGICAL OPERATOR, • TERNARY OPERATOR AND • ASSIGNMENT OPERATOR. • JAVA OPERATOR PRECEDENCE http://www.javatraininginjaipur.online/
  • 3. • JAVA UNARY OPERATOR EXAMPLE: ++ AND — class OperatorExample{ public static void main(String args[]){ int x=10; System.out.println(x++);//10 (11) System.out.println(++x);//12 System.out.println(x-- );//12 (11) System.out.println(--x);//10 }} Output: 10 12 12 10 http://www.javatraininginjaipur.online/
  • 4. • JAVA UNARY OPERATOR EXAMPLE 2: ++ AND — class OperatorExample{ public static void main(String args[]){ int a=10; int b=10; System.out.println(a++ + ++a);//10+12=22 System.out.println(b++ + b++);//10+11=21 }} Output: 22 21 Java Unary Operator Example: ~ and ! http://www.javatraininginjaipur.online/
  • 5. • JAVA UNARY OPERATOR EXAMPLE: ~ AND ! class OperatorExample{ public static void main(String args[]){ int a=10; int b=-0; boolean c=true; boolean d=false; System.out.println(~a);//-11 (minus of total positive value which starts from 0) System.out.println(~b);//9 (positive of total minus, positive starts from 0) System.out.println(!c);//false (opposite of boolean value) System.out.println(!d);//true }} Output: -11 9 false true http://www.javatraininginjaipur.online/
  • 6. Java Arithmetic Operator Example class OperatorExample{ public static void main(String args[]){ int a=10; int b=5; System.out.println(a+b);//15 System.out.println(a-b);//5 System.out.println(a*b);//50 System.out.println(a/b);//2 System.out.println(a%b);//0 }} Output:: 15 5 50 2 0 http://www.javatraininginjaipur.online/