SlideShare a Scribd company logo
Operators in JAVA
OperatorAn 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.
OperandsAn 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 integerTypes of OperatorsAssignment OperatorsIncrement Decrement OperatorsArithmetic OperatorsBitwise OperatorsRelational OperatorsLogical OperatorsTernary OperatorsComma OperatorsInstanceof Operators
Assignment OperatorsThe assignment statements has the following syntax:<variable> = <expression>
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: --
Increment and Decrement operators++ and --Common Shorthanda = a + 1;		a++; or ++a;a = a - 1;		a--; or --a;
Example of ++ and -- operatorspublic class Example {	public static void main(String[] args)   {	 }}int j, p, q, r, s;j = 5;p = ++j;  //  j = j + 1;  p = j;System.out.println("p = " + p);q = j++;  //  q = j;      j = j + 1;System.out.println("q = " + q);System.out.println("j = " + j);r = --j;  //  j = j -1;   r = j;System.out.println("r = " + r);s = j--;  //  s = j;      j = j - 1;System.out.println("s = " + s);> java examplep = 6q = 6j = 7r = 6s = 6>
Arithmetic OperatorsThe arithmetic operators are used to construct mathematical expressions as in algebra. Their operands are of numeric type.
Arithmetic Operators
Simple Arithmeticpublic class Example {	public static void main(String[] args) {		int j, k, p, q, r, s, t;		j = 5;		k = 2;		p = j + k;		q = j - k;		r = j * k;		s = j / k;		t = j % k;		System.out.println("p = " + p);		System.out.println("q = " + q);		System.out.println("r = " + r);		System.out.println("s = " + s);		System.out.println("t = " + t);	}} > java Example p = 7 q = 3 r = 10 s = 2 t = 1 >
Bitwise OperatorsJava'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 Operatorsclass Test { public static void main(String args[]) { int a = 60; /* 60 = 0011 1100 */ int b = 13; /* 13 = 0000 1101 */ int c = 0; c = a & b; /* 12 = 0000 1100 */ System.out.println("a & b = " + c ); c = a | b; /* 61 = 0011 1101 */ System.out.println("a | b = " + c );
Example Cont.,	c = a ^ b; /* 49 = 0011 0001 */ 	System.out.println("a ^ b = " + c ); 	c = ~a; /*-61 = 1100 0011 */ 	System.out.println("~a = " + c ); c = a << 2; /* 240 = 1111 0000 */ 	System.out.println("a << 2 = " + c ); c = a >> 2; /* 215 = 1111 */ System.out.println("a >> 2 = " + c ); c = a >>> 2; /* 215 = 0000 1111 */ System.out.println("a >>> 2 = " + c ); } }
Relational OperatorsA 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. 
Relational Operators
Relational Operators
Example of Relational Operatorspublic LessThanExample {publicstatic void main(String args[]) {	int a = 5; int b = 10;   	if(a < b) 	{System.out.println("a is less than b"); 	}	}	 }
Logical OperatorsThese logical operators work only on boolean operands. Their return values are always boolean.
Logical Operators
Example of Logical OperatorspublicclassANDOperatorExample{	publicstatic void main(String[] args){   	char ans = 'y'; 	int count = 1;   	if(ans == 'y' & count == 0){ 		System.out.println("Count is Zero.");}	if(ans == 'y' & count == 1) { System.out.println("Count is One."); }   	if(ans == 'y' & count == 2) { System.out.println("Count is Two."); } } }
Ternary OperatorsJava 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
Example of Ternary Operator// longhand with if:int answer; if ( a > b ){answer = 1; }else{answer = -1; 	}// can be written more tersely with the ternary operator as:int answer = a > b ? 1 : -1;
Comma OperatorsJava 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
Ad

More Related Content

What's hot (20)

Method overloading
Method overloadingMethod overloading
Method overloading
Lovely Professional University
 
Operators in java
Operators in javaOperators in java
Operators in java
Muthukumaran Subramanian
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
Lovely Professional University
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
Abhilash Nair
 
Control statements in java
Control statements in javaControl statements in java
Control statements in java
Madishetty Prathibha
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
RahulAnanda1
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
Nilesh Dalvi
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
Niloy Saha
 
Packages in java
Packages in javaPackages in java
Packages in java
Elizabeth alexander
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Tech_MX
 
C by balaguruswami - e.balagurusamy
C   by balaguruswami - e.balagurusamyC   by balaguruswami - e.balagurusamy
C by balaguruswami - e.balagurusamy
Srichandan Sobhanayak
 
Applets in java
Applets in javaApplets in java
Applets in java
Wani Zahoor
 
Interface in java
Interface in javaInterface in java
Interface in java
PhD Research Scholar
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
Pranali Chaudhari
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
tigerwarn
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
Abhilash Nair
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
narmadhakin
 
JVM
JVMJVM
JVM
baabtra.com - No. 1 supplier of quality freshers
 

Viewers also liked (20)

Operators and Expressions in Java
Operators and Expressions in JavaOperators and Expressions in Java
Operators and Expressions in Java
Abhilash Nair
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in java
Javed Rashid
 
Operators in java
Operators in javaOperators in java
Operators in java
Ravi_Kant_Sahu
 
Control structures in Java
Control structures in JavaControl structures in Java
Control structures in Java
Ravi_Kant_Sahu
 
Control statements in Java
Control statements  in JavaControl statements  in Java
Control statements in Java
Jin Castor
 
Constants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaConstants, Variables and Data Types in Java
Constants, Variables and Data Types in Java
Abhilash Nair
 
Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressions
vishaljot_kaur
 
Java basic
Java basicJava basic
Java basic
Sonam Sharma
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
Veerabadra Badra
 
Control structures i
Control structures i Control structures i
Control structures i
Ahmad Idrees
 
15 bitwise operators
15 bitwise operators15 bitwise operators
15 bitwise operators
Ravindra Rathore
 
Packages in java
Packages in javaPackages in java
Packages in java
Abhishek Khune
 
Control Structures
Control StructuresControl Structures
Control Structures
Ghaffar Khan
 
Operators in java
Operators in javaOperators in java
Operators in java
yugandhar vadlamudi
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
Pooja Jaiswal
 
Inheritance
InheritanceInheritance
Inheritance
Sapna Sharma
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
Raja Sekhar
 
Java packages
Java packagesJava packages
Java packages
Raja Sekhar
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
Manoj Tyagi
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
Intelligo Technologies
 
Operators and Expressions in Java
Operators and Expressions in JavaOperators and Expressions in Java
Operators and Expressions in Java
Abhilash Nair
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in java
Javed Rashid
 
Operators in java
Operators in javaOperators in java
Operators in java
Ravi_Kant_Sahu
 
Control structures in Java
Control structures in JavaControl structures in Java
Control structures in Java
Ravi_Kant_Sahu
 
Control statements in Java
Control statements  in JavaControl statements  in Java
Control statements in Java
Jin Castor
 
Constants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaConstants, Variables and Data Types in Java
Constants, Variables and Data Types in Java
Abhilash Nair
 
Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressions
vishaljot_kaur
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
Veerabadra Badra
 
Control structures i
Control structures i Control structures i
Control structures i
Ahmad Idrees
 
15 bitwise operators
15 bitwise operators15 bitwise operators
15 bitwise operators
Ravindra Rathore
 
Packages in java
Packages in javaPackages in java
Packages in java
Abhishek Khune
 
Control Structures
Control StructuresControl Structures
Control Structures
Ghaffar Khan
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
Pooja Jaiswal
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
Raja Sekhar
 
Java packages
Java packagesJava packages
Java packages
Raja Sekhar
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
Manoj Tyagi
 
Ad

Similar to Operators in java (20)

object oriented programming java lectures
object oriented programming java lecturesobject oriented programming java lectures
object oriented programming java lectures
MSohaib24
 
Pj01 4-operators and control flow
Pj01 4-operators and control flowPj01 4-operators and control flow
Pj01 4-operators and control flow
SasidharaRaoMarrapu
 
Java operators
Java operatorsJava operators
Java operators
Shehrevar Davierwala
 
Operators
OperatorsOperators
Operators
VijayaLakshmi506
 
05 operators
05   operators05   operators
05 operators
dhrubo kayal
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
Mohammed Saleh
 
Effective Java - Still Effective After All These Years
Effective Java - Still Effective After All These YearsEffective Java - Still Effective After All These Years
Effective Java - Still Effective After All These Years
Marakana Inc.
 
Java chapter 3
Java chapter 3Java chapter 3
Java chapter 3
Munsif Ullah
 
Java unit 3
Java unit 3Java unit 3
Java unit 3
Shipra Swati
 
ppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operatorsppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operators
Amrinder Sidhu
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
THE NORTHCAP UNIVERSITY
 
02basics
02basics02basics
02basics
Waheed Warraich
 
C++.pptx
C++.pptxC++.pptx
C++.pptx
Sabi995708
 
Chapter 2&3 (java fundamentals and Control Structures).ppt
Chapter 2&3 (java fundamentals and Control Structures).pptChapter 2&3 (java fundamentals and Control Structures).ppt
Chapter 2&3 (java fundamentals and Control Structures).ppt
henokmetaferia1
 
operators.pptx
operators.pptxoperators.pptx
operators.pptx
ruchisuru20001
 
Operators
OperatorsOperators
Operators
Daman Toor
 
4.Lesson Plan - Java Operators.pdf...pdf
4.Lesson Plan - Java Operators.pdf...pdf4.Lesson Plan - Java Operators.pdf...pdf
4.Lesson Plan - Java Operators.pdf...pdf
AbhishekSingh757567
 
Strings v.1.1
Strings v.1.1Strings v.1.1
Strings v.1.1
BG Java EE Course
 
C++
C++C++
C++
MuhammadSaad281
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++
bajiajugal
 
object oriented programming java lectures
object oriented programming java lecturesobject oriented programming java lectures
object oriented programming java lectures
MSohaib24
 
Pj01 4-operators and control flow
Pj01 4-operators and control flowPj01 4-operators and control flow
Pj01 4-operators and control flow
SasidharaRaoMarrapu
 
05 operators
05   operators05   operators
05 operators
dhrubo kayal
 
Effective Java - Still Effective After All These Years
Effective Java - Still Effective After All These YearsEffective Java - Still Effective After All These Years
Effective Java - Still Effective After All These Years
Marakana Inc.
 
Java chapter 3
Java chapter 3Java chapter 3
Java chapter 3
Munsif Ullah
 
ppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operatorsppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operators
Amrinder Sidhu
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
THE NORTHCAP UNIVERSITY
 
C++.pptx
C++.pptxC++.pptx
C++.pptx
Sabi995708
 
Chapter 2&3 (java fundamentals and Control Structures).ppt
Chapter 2&3 (java fundamentals and Control Structures).pptChapter 2&3 (java fundamentals and Control Structures).ppt
Chapter 2&3 (java fundamentals and Control Structures).ppt
henokmetaferia1
 
Operators
OperatorsOperators
Operators
Daman Toor
 
4.Lesson Plan - Java Operators.pdf...pdf
4.Lesson Plan - Java Operators.pdf...pdf4.Lesson Plan - Java Operators.pdf...pdf
4.Lesson Plan - Java Operators.pdf...pdf
AbhishekSingh757567
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++
bajiajugal
 
Ad

More from Then Murugeshwari (20)

Traffic safety
Traffic safetyTraffic safety
Traffic safety
Then Murugeshwari
 
P h indicators
P h indicatorsP h indicators
P h indicators
Then Murugeshwari
 
Avogadro's law
Avogadro's lawAvogadro's law
Avogadro's law
Then Murugeshwari
 
Resonance
ResonanceResonance
Resonance
Then Murugeshwari
 
Microwave remote sensing
Microwave remote sensingMicrowave remote sensing
Microwave remote sensing
Then Murugeshwari
 
Newton's law
Newton's lawNewton's law
Newton's law
Then Murugeshwari
 
Surface tension
Surface tensionSurface tension
Surface tension
Then Murugeshwari
 
Hook's law
Hook's lawHook's law
Hook's law
Then Murugeshwari
 
Hook's law
Hook's lawHook's law
Hook's law
Then Murugeshwari
 
ERP components
ERP componentsERP components
ERP components
Then Murugeshwari
 
Database fundamentals
Database fundamentalsDatabase fundamentals
Database fundamentals
Then Murugeshwari
 
Mosfet
MosfetMosfet
Mosfet
Then Murugeshwari
 
Operators
OperatorsOperators
Operators
Then Murugeshwari
 
Hiperlan
HiperlanHiperlan
Hiperlan
Then Murugeshwari
 
Bluetooth profile
Bluetooth profileBluetooth profile
Bluetooth profile
Then Murugeshwari
 
Router
RouterRouter
Router
Then Murugeshwari
 
Thread priorities
Thread prioritiesThread priorities
Thread priorities
Then Murugeshwari
 
Threads
ThreadsThreads
Threads
Then Murugeshwari
 
Identifiers
Identifiers Identifiers
Identifiers
Then Murugeshwari
 
Virtual ground
Virtual groundVirtual ground
Virtual ground
Then Murugeshwari
 

Recently uploaded (20)

Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from AnywhereAutomation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Lynda Kane
 
Rock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning JourneyRock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning Journey
Lynda Kane
 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersAutomation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Lynda Kane
 
Datastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptxDatastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptx
kaleeswaric3
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5..."Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
Fwdays
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from AnywhereAutomation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Lynda Kane
 
Rock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning JourneyRock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning Journey
Lynda Kane
 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersAutomation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Lynda Kane
 
Datastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptxDatastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptx
kaleeswaric3
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5..."Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
Fwdays
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 

Operators in java

  • 2. OperatorAn 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. OperandsAn operands are the values on which the operators act upon.An operand can be:A numeric variable - integer, floating point or character
  • 4. Any primitive type variable - numeric and boolean
  • 6. A literal - numeric value, boolean value, or string.
  • 7. An array element, "a[2]“
  • 8. char primitive, which in numeric operations is treated as an unsigned two byte integerTypes of OperatorsAssignment OperatorsIncrement Decrement OperatorsArithmetic OperatorsBitwise OperatorsRelational OperatorsLogical OperatorsTernary OperatorsComma OperatorsInstanceof Operators
  • 9. Assignment OperatorsThe assignment statements has the following syntax:<variable> = <expression>
  • 11. Increment and Decrement operators++ and --The increment and decrement operators add an integer variable by one.increment operator: two successive plus signs, ++decrement operator: --
  • 12. Increment and Decrement operators++ and --Common Shorthanda = a + 1; a++; or ++a;a = a - 1; a--; or --a;
  • 13. Example of ++ and -- operatorspublic class Example { public static void main(String[] args) { }}int j, p, q, r, s;j = 5;p = ++j; // j = j + 1; p = j;System.out.println("p = " + p);q = j++; // q = j; j = j + 1;System.out.println("q = " + q);System.out.println("j = " + j);r = --j; // j = j -1; r = j;System.out.println("r = " + r);s = j--; // s = j; j = j - 1;System.out.println("s = " + s);> java examplep = 6q = 6j = 7r = 6s = 6>
  • 14. Arithmetic OperatorsThe arithmetic operators are used to construct mathematical expressions as in algebra. Their operands are of numeric type.
  • 16. Simple Arithmeticpublic class Example { public static void main(String[] args) { int j, k, p, q, r, s, t; j = 5; k = 2; p = j + k; q = j - k; r = j * k; s = j / k; t = j % k; System.out.println("p = " + p); System.out.println("q = " + q); System.out.println("r = " + r); System.out.println("s = " + s); System.out.println("t = " + t); }} > java Example p = 7 q = 3 r = 10 s = 2 t = 1 >
  • 17. Bitwise OperatorsJava'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.
  • 19. Example of Bitwise Operatorsclass Test { public static void main(String args[]) { int a = 60; /* 60 = 0011 1100 */ int b = 13; /* 13 = 0000 1101 */ int c = 0; c = a & b; /* 12 = 0000 1100 */ System.out.println("a & b = " + c ); c = a | b; /* 61 = 0011 1101 */ System.out.println("a | b = " + c );
  • 20. Example Cont., c = a ^ b; /* 49 = 0011 0001 */ System.out.println("a ^ b = " + c ); c = ~a; /*-61 = 1100 0011 */ System.out.println("~a = " + c ); c = a << 2; /* 240 = 1111 0000 */ System.out.println("a << 2 = " + c ); c = a >> 2; /* 215 = 1111 */ System.out.println("a >> 2 = " + c ); c = a >>> 2; /* 215 = 0000 1111 */ System.out.println("a >>> 2 = " + c ); } }
  • 21. Relational OperatorsA 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. 
  • 24. Example of Relational Operatorspublic LessThanExample {publicstatic void main(String args[]) { int a = 5; int b = 10;   if(a < b) {System.out.println("a is less than b"); } } }
  • 25. Logical OperatorsThese logical operators work only on boolean operands. Their return values are always boolean.
  • 27. Example of Logical OperatorspublicclassANDOperatorExample{ publicstatic void main(String[] args){   char ans = 'y'; int count = 1;   if(ans == 'y' & count == 0){ System.out.println("Count is Zero.");} if(ans == 'y' & count == 1) { System.out.println("Count is One."); }   if(ans == 'y' & count == 2) { System.out.println("Count is Two."); } } }
  • 28. Ternary OperatorsJava 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
  • 29. Example of Ternary Operator// longhand with if:int answer; if ( a > b ){answer = 1; }else{answer = -1; }// can be written more tersely with the ternary operator as:int answer = a > b ? 1 : -1;
  • 30. Comma OperatorsJava 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
  • 31. Example of Comma Operator//: c03:CommaOperator.java// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002// www.BruceEckel.com. See copyright notice in CopyRight.txt.public class CommaOperator {  public static void main(String[] args) {    for(int i = 1, j = i + 10; i < 5;        i++, j = i * 2) {      System.out.println("i= " + i + " j= " + j);    }  }} ///:~                    
  • 32. Instanceof OperatorsThis 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 wriiten as:
  • 34. The End ….. Thank You …..