+ 10
what is unary operator in java
3 Réponses
+ 18
The unary operators requires only one operand to perform different kind of operations such as increasing/decreasing a value, negating an expression, or inverting a boolean value.
For eg.,
- the increment (++) and decrement(--) operators are unary :
int x = 0;
int y = 0;
y = ++x;
System.out.println(x);
System.out.println(y);
}
}
// The output of this program shows that always 1 is stored in both variables i.e. the value of "x" is incremented first then it is assigned to the variable "y".
There are many more examples here :
http://www.roseindia.net/java/master-java/unary-operators.shtml
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/op1.html
+ 2
ok
+ 2
ok very good