Operators in Java
Operators in Java
com [Page-1]
Operators In Java
An operator is a symbol by which certain operation can be performed.
Types of Operators – Based on the nature, the operators are classified into various
types which are-
Unary Operator – Unary means one, i.e An unary operator can be applied on single
operand only.
Post Increment Operator – It returns the value first then increment it by one.
for e.g-
int j = 0;
System.out.println(j++); // this line will print 0
System.out.println(j); // this line will print 1
Lets see in the below example to understand how post increment and pre increment expression
gets evaluated.
Online Training [Topic->Operators In Java] www.wayofcoding.com [Page-3]
Bitwise Complement Operator – It flips all bits in binary and hence positive number becomes
negative and vice versa.
for e.g-
int k = 5;
int z = -10;
System.out.println(~k); // this line will print -6
System.out.println(~z); // this line will print 9
Online Training [Topic->Operators In Java] www.wayofcoding.com [Page-4]
Logical AND && Operator – It returns true only if both condition are true otherwise it
returns false. Note that if first condition is false then second condition does not get evaluated.
Logical OR || Operator – It returns true if any condition is true otherwise it returns false.
Note that if first condition is true then second condition does not get evaluated.
Online Training [Topic->Operators In Java] www.wayofcoding.com [Page-7]