SlideShare a Scribd company logo
Java Operators
An overview of different operators used in Java programming.
Introduction
This presentation provides a detailed examination of Java operators
including arithmetic, logical, relational, and more, along with their
usage and examples.
Arithmetic
Operators
01
Definition and Usage
Arithmetic operators are used to perform mathematical operations on variables
and values. They include addition, subtraction, multiplication, and division.
Common
Operations
Key arithmetic operators include:
1. Addition (+)
2. Subtraction (-)
3. Multiplication (*)
4. Division (/)
5. Modulus (%) which finds the remainder.
Examples
For example:
1. int result = a + b; // Addition
2. int result = a - b; // Subtraction
3. int result = a * b; // Multiplication
4. int result = a / b; // Division
5. int result = a % b; // Modulus
Logical
Operators
02
Definition and
Purpose
Logical operators are used to combine
multiple boolean expressions. They
include AND (&&), OR (||), and NOT (!).
Operation Types
1. AND (&&) - true if both operands are true.
2. OR (||) - true if at least one operand is true.
3. NOT (!) - reverses the boolean value of an operand.
Examples
For example:
1. boolean result = (a > b) && (b < c);
2. boolean result = (a < b) || (b > c);
3. boolean result = !(a == b);
Relational
Operators
03
Definition and Application
Relational operators are used to compare two values and return a boolean result
(true or false). They include equal to, not equal to, greater than, less than, and
so on.
Comparison
Functions
Common relational operators include:
1. Equal to (==)
2. Not equal to (!=)
3. Greater than (>)
4. Less than (<)
5. Greater than or equal to (>=)
6. Less than or equal to (<=)
Examples
For example:
1. if (a == b) { ... }
2. if (a != b) { ... }
3. if (a > b) { ... }
4. if (a < b) { ... }
Assignment
Operators
04
Basic
Assignment
Assignment operators assign values to
variables. The main operator is the
equal sign (=).
Combined Operations
Combined assignment operators modify the value of a variable based on its
current value:
1. +=, -=, *=, /=, %=.
Examples
For example:
1. int result = a & b; // Bitwise AND
2. int result = a | b; // Bitwise OR
3. int result = a ^ b; // Bitwise XOR
4. int result = ~a; // Bitwise NOT
5. int result = a << 2; // Left shift
6. int result = a >> 2; // Right shift
Bitwise
Operators
05
Definition and Functions
Bitwise operators perform operations on individual bits of integer values. They
are used for low-level programming, such as hardware manipulation and
encryption techniques.
Types of Bitwise Operations
1. Bitwise AND (&)
2. Bitwise OR (|)
3. Bitwise XOR (^)
4. Bitwise NOT (~)
5. Left Shift (<<)
6. Right Shift (>>).
Examples
For example:
1. int a = 5; // 0101 in binary
2. int b = 3; // 0011 in binary
3. Bitwise AND: a & b results in 1 (0001).
4. Bitwise OR: a | b results in 7 (0111).
Unary
Operators
06
Definition and Types
Unary operators are operators that operate on a single operand and include:
1. Unary plus (+)
2. Unary minus (-)
3. Increment (++)
4. Decrement (--).
Increment and Decrement
Increment (++) increases the value of a variable by one.
Decrement (--) decreases the value of a variable by one. They can be used in
either prefix or postfix notation.
Examples
For example:
1. int a = 5;
2. int b = ++a; // a becomes 6
3. int c = a--; // c becomes 6, a becomes 5 again
Conditional
Operator
07
Definition and Syntax
The conditional operator (?:) is a shortcut for the if-else statement. It takes three
operands and evaluates one of the two expressions based on a boolean
condition.
Usage Scenarios
Used for concise conditional expressions:
- Assigning a value based on a condition.
- Evaluating small conditional logic without multiple lines of code.
Examples
For example:
1. int max = (a > b) ? a : b;
2. String result = (isTrue) ? "Yes" : "No";
instanceof
Operator
08
Definition and
Purpose
The instanceof operator checks whether an
object is an instance of a specific class or
subclass. It returns true if the object is of
the specified type, otherwise false.
Type Checking
Used frequently in polymorphism to determine the actual object type
during runtime. This helps avoid ClassCastException.
Examples
For example:
1. if (obj instanceof String) { ... }
2. if (a instanceof ParentClass) { ... }
Conclusions
In summary, understanding Java operators is essential for effective
programming. Each operator serves a specific purpose, allowing developers to
perform various operations and make logical evaluations efficiently.
CREDITS: This presentation template was created by Slidesgo, and
includes icons by Flaticon, and infographics & images by Freepik
Thank you!
Do you have any questions?

More Related Content

PPTX
Java Operators with Simple introduction.pptx
PPT
4_A1208223655_21789_2_2018_04. Operators.ppt
DOCX
Operators
PDF
Java basic operators
PDF
Java basic operators
PDF
itft-Operators in java
PPTX
Oop using JAVA
PPTX
PPT ON JAVA AND UNDERSTANDING JAVA'S PRINCIPLES
Java Operators with Simple introduction.pptx
4_A1208223655_21789_2_2018_04. Operators.ppt
Operators
Java basic operators
Java basic operators
itft-Operators in java
Oop using JAVA
PPT ON JAVA AND UNDERSTANDING JAVA'S PRINCIPLES

Similar to Java Operators with Simple introduction.pptx (20)

PPTX
Lecture-02-JAVA, data type, token, variables.pptx
PPTX
L3 operators
PPTX
L3 operators
PPTX
L3 operators
PPTX
OOPJ_PPT2,JAVA OPERATORS TPYE WITH EXAMPLES.pptx
PPTX
Opeartor &amp; expression
PPTX
Arithmetic Operators ____ java.pptx
PPTX
Operators
PPTX
presentation on array java program operators
PPT
object oriented programming java lectures
PPTX
Operators in java By cheena
PPTX
Computer programming 2 Lesson 7
PPTX
ChapterTwoandThreefnfgncvdjhgjshgjdlahgjlhglj.pptx
PPTX
Java chapter 3
PPTX
11operator in c#
PPTX
Pj01 4-operators and control flow
PPTX
OCA Java SE 8 Exam Chapter 2 Operators & Statements
PDF
8- java language basics part2
PPT
3.OPERATORS_MB.ppt .
ODP
Operators
Lecture-02-JAVA, data type, token, variables.pptx
L3 operators
L3 operators
L3 operators
OOPJ_PPT2,JAVA OPERATORS TPYE WITH EXAMPLES.pptx
Opeartor &amp; expression
Arithmetic Operators ____ java.pptx
Operators
presentation on array java program operators
object oriented programming java lectures
Operators in java By cheena
Computer programming 2 Lesson 7
ChapterTwoandThreefnfgncvdjhgjshgjdlahgjlhglj.pptx
Java chapter 3
11operator in c#
Pj01 4-operators and control flow
OCA Java SE 8 Exam Chapter 2 Operators & Statements
8- java language basics part2
3.OPERATORS_MB.ppt .
Operators
Ad

Recently uploaded (20)

PDF
English Language Teaching from Post-.pdf
PPTX
Introduction and Scope of Bichemistry.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Business Ethics Teaching Materials for college
PDF
Pre independence Education in Inndia.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Pharma ospi slides which help in ospi learning
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PDF
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
English Language Teaching from Post-.pdf
Introduction and Scope of Bichemistry.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Business Ethics Teaching Materials for college
Pre independence Education in Inndia.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Pharma ospi slides which help in ospi learning
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
NOI Hackathon - Summer Edition - GreenThumber.pptx
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
Abdominal Access Techniques with Prof. Dr. R K Mishra
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
Week 4 Term 3 Study Techniques revisited.pptx
Ad

Java Operators with Simple introduction.pptx