I was writing this code in eclipse, it war written, and the result is 3d
.
public static void main(String[] args) {
double a = 5d + + + + + +-+3d;
System.out.println(a);
}
Your expression can be rewritten as
(5d) + (+ + + + +-+3d)
Where the first +
is the addition operator applied to two operands.
All the +
and -
in + + + + +-+3d
are unary operators that add up to the sign of the number 3d
.
In the end, your arithmetic expression is
5d + (-3d)
Which returns 2d
. You can apply multiple unary operators to an expression, as in the following examples:
+ - - 2 // 2
- + + 2 // -2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With