int
to
a float
, you will get a float
. If you
add a float
to a double
you will get a
double
.
The format used in the descriptions below is:
syntax
+
value_2
String
, all operands are converted
to String
s and are then concatenated together. So,
3.4 + 5;
"One is "+1+" and all alone";
-
value_2
*
value_2
/
value_2
%
value_2
%
value_2. This operator is
useful only if value_1 and value_2 are both integers,
in which case it is equvalent to value_1-(value_1/value_2)*value_1;
.
=
value
class
as its type, value must be an object of type class
.
If variable is one of the
primitive data types, then promotion is allowed as described
above.
++
OR
++
variable
int x=3; int y=x++; System.out.println("x is "+x+". y is "+y+".");would output x is 4. y is 3. whereas
int x=3; int y=++x; System.out.println("x is "+x+". y is "+y+".");would output x is 4. y is 4..
--
OR
--
variable
+=
value
=
variable +
value.
-=
value
=
variable -
value.
-=
value
=
variable *
value.
/=
value
=
variable /
value.
![]() |
6.8 Boolean Operators |