2. OPERATOR
It is a special symbols performing specific
operations on one, two or three operands and
then returning a result.
Java provides a rich set of operators to
manipulate variables
Kunal
3. Operands
An operand is the quantity on which an operation is to be done..
An operand can be:
o A numeric variable - integer, floating point or
character
O Any primitive type variable - numeric and Boolean.
o Reference variable to an object
o A literal - numeric value, Boolean value, or string.
o An array element, "a[2]“
o char primitive, which in numeric operations is
treated as an unsigned two byte integer
Kunal
5. ASSIGNMENT OPERATORS
An assignment operator is the operator used to assign a new value
to a variable
The assignment statements has the following syntax:
<variable> = <expression>
for ex:
int a, b;
a=2; // 2 is assigned to variable a
b=3; // 3 is assigned to variable b
Kunal
6. INCREMENT AND DECREMENT OPERATORS
++ AND --
Increment (++) and decrement (--) operators in Java programming
lets us easily add 1 to, or subtract 1 from, a variable. For example,
using increment operators, you can add 1 to a variable named a like
this: a++; An expression that uses an increment or decrement operator
is a statement itself.
two successive plus signs, ++
decrement operator: --
for example:
a=a+1;
b=b+1;
a++ ; or ++a ;
b-- ; or –b ;
Kunal
7. ARITHMETIC OPERATORS
The arithmetic operators are used to construct
mathematical expressions as in algebra.
Their operands are of numeric type.
Example of arithmetic operators are;
+ , - , * , / , etc
Kunal
8. BITWISE OPERATORS
A bitwise operation operates on one or more
bit patterns or binary numerals at the level of
their individual bits.
If an operand is shorter than an int, it is
promoted to int before
doing the operations.
for example ::
& ,| , ^ ,~ , << , >> , >>>
Kunal
9. RELATIONAL OPERATORS
A 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.
for example:
== , != , > , >= , <=
Kunal
10. LOGICAL OPERATORS
A logical operator (sometimes called a
“Boolean operator”) in Java programming is an
operator that returns a Boolean result that's
based on the Boolean result of one or two other
expressions
for example:
&& , || , !
Kunal
11. TERNARY OPERATORS
This operator consists of three operands and is
used to evaluate Boolean expressions. The goal of
the operator is to decide; which value should be
assigned to the variable.
Unlike the if statement, the conditional
operator is an
expression which can be used for
example of ternary operator:
int answer;
if ( a > b )
{
answer = 1;
}
else
{
answer = -1;
}
12. Shift operators
The shift operators, << (shift left), and >> (shift
right), take two integers as operands. They
return the result of shifting the bits of the left
operand by the number of positions specified by
the right operand. The left shift operator shifts
bits to the left, and the right shift operator shifts
bits to the right.
13. INSTANCE OF OPERATORS
This operator is used only for object reference
variables. The
operator checks whether the object is of a
particular type(class
type or interface type).
Instance Of operator is written as:
( Object reference variable ) instance Of
(class/interface type)
Kunal
A REFRENCEVARIABLE ISAVARIABLEWHICH IS DEC LARED FOR SPECIFICTYPE
ANDWHOSETYPE IS NEVERGONNA CHANGE