0% found this document useful (0 votes)
4 views13 pages

Java Operators Explained: Types & Functions

The document provides an overview of operators in Java, categorizing them based on the number of operands: unary, binary, and ternary. It details various types of operators including arithmetic, assignment, relational, logical, conditional, increment/decrement, and bitwise operators, along with their functions and examples. Additionally, it explains the operations of increment and decrement operators in both pre- and post- forms.

Uploaded by

kavirechiks
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views13 pages

Java Operators Explained: Types & Functions

The document provides an overview of operators in Java, categorizing them based on the number of operands: unary, binary, and ternary. It details various types of operators including arithmetic, assignment, relational, logical, conditional, increment/decrement, and bitwise operators, along with their functions and examples. Additionally, it explains the operations of increment and decrement operators in both pre- and post- forms.

Uploaded by

kavirechiks
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

OPERATORS IN JAVA

TYPES OF OPERATORS
Operator- Is a predefined symbol which is used to perform a specific task
on the given data. The data given as a input to the operator is called as
operand.
operato
r
5+6= expressio
11 n

operan
ds
Based on the number of operands, operators are classified as:
TYPES OF OPERATORS(Based on
operands

Unary Binary Ternary


TYPES OF
OPERATORS(Based on the
number of operands

Unary Binary Ternary

The operator which can accept The operator which can The operator which can
only one operand is known as accept two operands is accept three operands
unary operator. known as binary operator. operand is known as unary
operator.

Classification of operators

1. Ari thematic operator


2. Assignment operator
3. Relational operator
4. Logical operator
5. Increment / Decrement operator
6. Conditional operator
7. Miscellaneous
8. Bitwise operator
ARI THEMATIC OPERATORS
Operator Operation
+ Addition
- Subtraction
* Multiply
/ Division
% Modulus(Remainder after
division)
ASSIGNMENT OPERATORS
Operator Example Equivalent to

= a=5; Assign a value

+= a+=b; a=a+b;
-= a-=b; a=a-b
*= a*=b; a=a*b

/= a/=b; a=a/b

%= a%=b; a=a%b
RELATIONAL OPERATORS
Compare the relation between to operands
5>2 (true)
5<2 (false)
5==5 (true)
5>=5 (true)
5>=2 (true)
5 >=17 (false)
5 != 2 (true)
5!=5 (false)
RELATIONAL OPERATOR
Operator Function
== Is equal to
!= Not equal to
> Greater than
< Less than
>= Greater
<= Less than
LOGICAL OPERATOR
Operator Function
&&(logical AND) If all the expression returns true
then this operator will return
true.
||(Logical OR) If any of one of the expression
return true then this operator
will return true.
!(Logical NOT)
If the result is true then it will
return false and vice-versa.
Operand Operand Output Operand Operand Output
1 2 1 2
true true true True true true

true false false true false true

false true false false true true

false false false false false false

&& ||
operator Operand Operand operator
1 2
true false
false true
!
operator
CONDITIONAL OPERATOR
It is a ternary operator
• The return type of operand 1 must
Syntax : be Boolean
Operand 1 ? Operand 2 : Operand 3; • If the condition is true , statement 1
will get executed else statement 2
Statement 1 ? Statement 2 : will get executed.
Statement 3;
op1 ? op2 : op3

tru Executes
e operand 2
false Executes
operand 3
INCREMENT AND
DECREMENT OPERATORSPre-Increment
operator
Increment
operators

Post-
Increment Increment
and operator
decrement
operators
Pre-
Decrement
Decrement operators
operators
Post-
Decrement
operators
INCREMENT OPERATOR
Operator Operations

++a (pre-increment) I. Increment the value by 1 and update


II. Substitute the updated value
III. Use the substituted value
Operator Operations

a++(post-increment) I. Substitute
II. Increase the value by 1
III. Use the substituted value
DECREMENT OPERATOR
Operator Operations

--a (pre-decrement) I. Decrease the value by 1 and update


II. Substitute the updated value
III. Use the substituted value
Operator Operations

A--(post-decrement) I. Substitute
II. Decrease the value by 1
III. Use the substituted value

You might also like