Is there a Java function to convert a positive int to a negative one and a negative int to a positive one?
I\'m looking for a reverse
function to perfor
Just use the unary minus operator:
int x = 5;
...
x = -x; // Here's the mystery library function - the single character "-"
Java has two minus operators:
0 - x
), andThis compiles and works as expected.