Java Reference
In-Depth Information
Table 4-5.
(
continued
)
Operator
Name
Syntax
Description
/
op1 / op2
Division
Preforms division and returns the
quotient of the two operands.
*
Multiplication
op1 * op2
Performs multiplication and returns
product of the operands.
%
op1 % op2
Remainder
Uses the left operand as the dividend
and the right operand as the divisor of
a division operation and returns the
remainder.
in
prop in obj
Returns
true
if the
obj
contains a
property named
prop
. Otherwise, returns
false. Here,
prop
is a string or a value
convertible to string and
obj
is an object.
instanceof
obj
instanceof
cls
Returns
true
of
obj
is an instance of the
class
cls
. Otherwise, return
false
.
<
op1 < op2
Returns
true
of
op1
is less than
op2
.
Otherwise, returns
false
.
Less-than
<=
op1 <= op2
Returns
true
of
op1
is less than or equal
to
op2
. Otherwise, returns
false
.
Less-than-or-
equal
>
op1 > op2
Returns
true
of
op1
is greater than
op2
.
Otherwise, returns
false
.
Greater-than
>=
op1 >= op2
Returns
true
of
op1
is greater than or
equal to
op2
. Otherwise, returns
false
.
Greater-than-
or-equal
==
op1 == op2
Returns
true
if
op1
and
op2
are equal.
Otherwise, returns
false
. Type
conversions are applied, if necessary. For
example,
"2" == 2
returns
true
because
the string
"2"
s converted to the number
2
and then both operands are equal.
Equality
!=
op1 != op2
Returns
true
if
op1
and
op2
are not
equal. Otherwise, returns
false
. Type
conversions are applied, if necessary.
Inequality
===
op1 === op2
Returns
true
if the types and values of the
two operands are the same. Otherwise,
returns
false
. The expression,
"2" ===
2
returns
false "2"
is a string and
2
is a
number. Both expressions
"2" === "2"
and
2 === 2
return
true
.
Identity or
strict equality
(
continued
)
Search WWH ::
Custom Search