SlideShare a Scribd company logo
P.1
Operators
ghadeer-al-hasan ghadeerof@gamil.com
Java Operators : P.2
Java provides a rich set of operators to manipulate variables:
 Arithmetic Operators
 Relational Operators
 Bitwise Operators
 Logical Operators
 Assignment Operators
 Miscellaneous Operators
The Arithmetic Operators: P.3
The Relational Operators: P.4
Operators Description
== (equal to) Checks if the values of two operands are equal or not,
if yes then condition becomes true
!= ( not equal to) Checks if the values of two operands are equal or not,
if values are not equal then condition become true
> ( greater than) Checks if the value of left operand is greater than the
value of right operand, if yes then condition become
true
< ( less than) Checks if the value of left operand is less than the
value of right operand, if yes then condition become
true
>= (greater than or equal to) Checks if the value of left operand is greater than or
equal to the value of right operand, if yes then
condition becomes true.
<= ( less than or equal to ) Checks if the value of left operand is less than or equal
to the value of right operand, if yes then condition
becomes true
The Bitwise Operators: P.5
Java defines several bitwise operators, which can be applied to
the integer types, long, int, short, char, and byte.
X = 1
X<<3 = 1000
X>>4 = 00001
----------------
Y = 0101
Y<<2 = 0100
Y>>2 = 0001
----------------
Y <<= 2
 Y = Y<<2
----------------
Y>>= 2
 Y= Y>>2
A = 0011 1010
B = 1010 1101
----------------
A & B = 0010 1000
A | B = 1011 1111
A ^ B = 1001 0111
~ A = 1100 0101
I = 0
I + = 2
 I = 2
--------
J = 2
J *= 5
 J =10
X Y X & Y X | Y X^Y
0 0 0 0 0
0 1 0 1 1
1 0 0 1 1
1 1 1 1 0
The Logical Operators: P.6
A B A&&B A||B
False False False False
False True False True
True False False True
True True True True
C ! C
True False
False True
The Assignment Operators: P.7
Operator Description Operator Description
= C = A+B += (C += A) C = C+A
-= (C -=A) C = C – A *= (C *= A) C = C * A
/= (C /= A) C = C / A %= (C %= A) C = C % A
<<= (C <<= A) C = C<<A >>= (C >>=A) C= C>>A
&= (C &= A) C = C & A ^= (C^= A) C = C^ A
|= (C |= A) C = C | A
Miscellaneous Operators: P.8
Conditional Operator:
is also known as the ternary operator, This operator consists of three operands
and is used to evaluate Boolean expressions
Instance of Operator: P.9
Is used only for object reference variable, the operator checks whether
The object is of a particular type (class type or interface type).
Example: P.10
P.11
Decision Making
If-else: P.12
Loop Control: P.13
Loop Control Cont. : P.14
Number Class : P.15
 Is Wrapper classes
 Integer, Long, Byte, Double, Float, Short are subclasses of the abstract class Number
Number methods : P.16
Number method Cont. : P.17
Number method Cont. : P.18
 ecp(), log(), pow(), sqrt()
 sin(), cos(), tan()
 atan, acos, asin(), atan2
 toRadians(), ToDegress()
 random()
Character Class : P.19
The Character class offers a number of useful class methods
For manipulating characters, You can create a Character object
With the Character constructor.
Escape Sequences :
A character preceded by backslash () is an escape sequence and has
special meaning to the compiler
Escape Sequences Cont. : P.20
Escape Sequence Description
t Insert a tab in the text at this point
b Insert a backspace in the text at this point
n Insert a newline in the text at this point
’ Insert a single quote character in the text at this point
” Insert a double quote character in the text at this point
 Insert a backslash character in the text at this point
Character Methods : P.21
Methods Description
isLetter() Determines whether the specified char value is a letter
isDigit() Determines whether the specified char value is a digit
isWhiespace() Determines whether the specified char value is white space
isUpperCase() Determines whether the specified char value is uppercase
isLowerCase() Determines whether the specified char value is lowercase
toUpperCase() Returns the uppercase form of the specified char value
toLowerCase() Returns the lowercase form of the specified char value
toString() Return a String object representing the specified character
value ,that is a one-character string
Scanner Class : P.22
 It has methods for Input
 Import the package java.util
Java program
Input StreamOutput Stream
 System.in – the input stream : is connected to the keyboard and the data are character
 System.out – the output stream for normal results: connected to the monitor
and also are character data
 System.err – the output stream for error message: connected to the monitor,
and also are character data
Example : P.23
The End
ghadeer-al-hasan ghadeerof@gamil.com

More Related Content

PDF
itft-Operators in java
PPTX
Operators in java
PDF
Operators in java
PPTX
Operators in java presentation
PPTX
OCA JAVA - 3 Programming with Java Operators
PPT
PDF
Java basic operators
PPTX
05 operators
itft-Operators in java
Operators in java
Operators in java
Operators in java presentation
OCA JAVA - 3 Programming with Java Operators
Java basic operators
05 operators

What's hot (19)

PPT
Expressions in c++
PPTX
Operators and Expressions
PDF
Operators in python
PPTX
Operators in C & C++ Language
PPTX
Operators in python
PPTX
Operators in Python
PPTX
Operators in c++
PPTX
Python Operators
PDF
Python : basic operators
PPT
C Prog. - Operators and Expressions
PPT
Operators
PPTX
DOC
Report on c
PPT
Operator & Expression in c++
PDF
Operators in python
PPT
C Sharp Jn (2)
PPT
PPTX
Logical Operators C/C++ language Programming
PDF
Operators in c programming
Expressions in c++
Operators and Expressions
Operators in python
Operators in C & C++ Language
Operators in python
Operators in Python
Operators in c++
Python Operators
Python : basic operators
C Prog. - Operators and Expressions
Operators
Report on c
Operator & Expression in c++
Operators in python
C Sharp Jn (2)
Logical Operators C/C++ language Programming
Operators in c programming
Ad

Similar to 3- Operators in Java (20)

PPTX
Python programming language introduction unit
PDF
ESIT135 Problem Solving Using Python Notes of Unit-1 and Unit-2
DOCX
Programming Fundamentals lecture 7
PDF
23CSC101T PSPP python programming - UNIT 3.pdf
PDF
23CSC101T PSPP python program - UNIT 3.pdf
PPTX
Operators
PPT
2. operators in c
PPTX
PPT ON JAVA AND UNDERSTANDING JAVA'S PRINCIPLES
PPTX
Operators and expressions in C++
PPTX
Computer programming 2 Lesson 7
PPTX
Operators In Java Part - 8
PPTX
C PRESENTATION.pptx
PPTX
C operators
PDF
Programming C Part 02
DOCX
C – operators and expressions
PPTX
Operator 04 (js)
PPTX
operatorsincprogramming-190221094522.pptx
PPTX
Operators in java
PPTX
Structured Programming Unit-4-Operators-and-Expression.pptx
Python programming language introduction unit
ESIT135 Problem Solving Using Python Notes of Unit-1 and Unit-2
Programming Fundamentals lecture 7
23CSC101T PSPP python programming - UNIT 3.pdf
23CSC101T PSPP python program - UNIT 3.pdf
Operators
2. operators in c
PPT ON JAVA AND UNDERSTANDING JAVA'S PRINCIPLES
Operators and expressions in C++
Computer programming 2 Lesson 7
Operators In Java Part - 8
C PRESENTATION.pptx
C operators
Programming C Part 02
C – operators and expressions
Operator 04 (js)
operatorsincprogramming-190221094522.pptx
Operators in java
Structured Programming Unit-4-Operators-and-Expression.pptx
Ad

More from Ghadeer AlHasan (20)

PPTX
[C++ Tutorial ] #9 Classes
PPTX
[C++ Tutorial] #8 Files
PPTX
[C++ Tutorial] #7- Linked List
PPTX
[Java] #8 String and Inner Class
PPTX
[C++ Tutorial] #6- Pointers
PPTX
[Java] #7 - Input & Output Stream
PPTX
[C++] #5 - Structures
PPTX
#6- Arrays and Collections Framework
PPTX
5- Overriding and Abstraction In Java
PPTX
4- Inheritance, Aggregation, Encapsulation and Overloading
PPTX
2- Introduction to java II
PPTX
1- Introduction to java
PPTX
0- Overview
PPTX
4- Arrays
PPTX
3- Functions
PPTX
2- Control Structures
PPTX
1- Languages Basics
PPTX
#8 (Java Message Service)
PPTX
#7 (Java Message Service)
PPTX
#6 (RESTtful Web Wervices)
[C++ Tutorial ] #9 Classes
[C++ Tutorial] #8 Files
[C++ Tutorial] #7- Linked List
[Java] #8 String and Inner Class
[C++ Tutorial] #6- Pointers
[Java] #7 - Input & Output Stream
[C++] #5 - Structures
#6- Arrays and Collections Framework
5- Overriding and Abstraction In Java
4- Inheritance, Aggregation, Encapsulation and Overloading
2- Introduction to java II
1- Introduction to java
0- Overview
4- Arrays
3- Functions
2- Control Structures
1- Languages Basics
#8 (Java Message Service)
#7 (Java Message Service)
#6 (RESTtful Web Wervices)

Recently uploaded (20)

PDF
medical staffing services at VALiNTRY
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
System and Network Administration Chapter 2
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Nekopoi APK 2025 free lastest update
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
Transform Your Business with a Software ERP System
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Essential Infomation Tech presentation.pptx
PPTX
Operating system designcfffgfgggggggvggggggggg
medical staffing services at VALiNTRY
How to Migrate SBCGlobal Email to Yahoo Easily
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
Design an Analysis of Algorithms II-SECS-1021-03
System and Network Administration Chapter 2
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Odoo Companies in India – Driving Business Transformation.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Nekopoi APK 2025 free lastest update
How Creative Agencies Leverage Project Management Software.pdf
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Transform Your Business with a Software ERP System
CHAPTER 2 - PM Management and IT Context
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Essential Infomation Tech presentation.pptx
Operating system designcfffgfgggggggvggggggggg

3- Operators in Java

  • 2. Java Operators : P.2 Java provides a rich set of operators to manipulate variables:  Arithmetic Operators  Relational Operators  Bitwise Operators  Logical Operators  Assignment Operators  Miscellaneous Operators
  • 4. The Relational Operators: P.4 Operators Description == (equal to) Checks if the values of two operands are equal or not, if yes then condition becomes true != ( not equal to) Checks if the values of two operands are equal or not, if values are not equal then condition become true > ( greater than) Checks if the value of left operand is greater than the value of right operand, if yes then condition become true < ( less than) Checks if the value of left operand is less than the value of right operand, if yes then condition become true >= (greater than or equal to) Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. <= ( less than or equal to ) Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true
  • 5. The Bitwise Operators: P.5 Java defines several bitwise operators, which can be applied to the integer types, long, int, short, char, and byte. X = 1 X<<3 = 1000 X>>4 = 00001 ---------------- Y = 0101 Y<<2 = 0100 Y>>2 = 0001 ---------------- Y <<= 2  Y = Y<<2 ---------------- Y>>= 2  Y= Y>>2 A = 0011 1010 B = 1010 1101 ---------------- A & B = 0010 1000 A | B = 1011 1111 A ^ B = 1001 0111 ~ A = 1100 0101 I = 0 I + = 2  I = 2 -------- J = 2 J *= 5  J =10 X Y X & Y X | Y X^Y 0 0 0 0 0 0 1 0 1 1 1 0 0 1 1 1 1 1 1 0
  • 6. The Logical Operators: P.6 A B A&&B A||B False False False False False True False True True False False True True True True True C ! C True False False True
  • 7. The Assignment Operators: P.7 Operator Description Operator Description = C = A+B += (C += A) C = C+A -= (C -=A) C = C – A *= (C *= A) C = C * A /= (C /= A) C = C / A %= (C %= A) C = C % A <<= (C <<= A) C = C<<A >>= (C >>=A) C= C>>A &= (C &= A) C = C & A ^= (C^= A) C = C^ A |= (C |= A) C = C | A
  • 8. Miscellaneous Operators: P.8 Conditional Operator: is also known as the ternary operator, This operator consists of three operands and is used to evaluate Boolean expressions
  • 9. Instance of Operator: P.9 Is used only for object reference variable, the operator checks whether The object is of a particular type (class type or interface type).
  • 15. Number Class : P.15  Is Wrapper classes  Integer, Long, Byte, Double, Float, Short are subclasses of the abstract class Number
  • 18. Number method Cont. : P.18  ecp(), log(), pow(), sqrt()  sin(), cos(), tan()  atan, acos, asin(), atan2  toRadians(), ToDegress()  random()
  • 19. Character Class : P.19 The Character class offers a number of useful class methods For manipulating characters, You can create a Character object With the Character constructor. Escape Sequences : A character preceded by backslash () is an escape sequence and has special meaning to the compiler
  • 20. Escape Sequences Cont. : P.20 Escape Sequence Description t Insert a tab in the text at this point b Insert a backspace in the text at this point n Insert a newline in the text at this point ’ Insert a single quote character in the text at this point ” Insert a double quote character in the text at this point Insert a backslash character in the text at this point
  • 21. Character Methods : P.21 Methods Description isLetter() Determines whether the specified char value is a letter isDigit() Determines whether the specified char value is a digit isWhiespace() Determines whether the specified char value is white space isUpperCase() Determines whether the specified char value is uppercase isLowerCase() Determines whether the specified char value is lowercase toUpperCase() Returns the uppercase form of the specified char value toLowerCase() Returns the lowercase form of the specified char value toString() Return a String object representing the specified character value ,that is a one-character string
  • 22. Scanner Class : P.22  It has methods for Input  Import the package java.util Java program Input StreamOutput Stream  System.in – the input stream : is connected to the keyboard and the data are character  System.out – the output stream for normal results: connected to the monitor and also are character data  System.err – the output stream for error message: connected to the monitor, and also are character data