Java examples for Language Basics:Operator
Using the Unary Plus and Minus Operators
int a = 5; // a is 5 int b = -a; // b is -5 int c = -b; // c is +5 int a = -5; // a is -5 int b = +a; // b is -5 a = 5; // a is now 5 int c = +a; // c is 5
public class Main { public static void main(String[] args) { int a = 3, b = 4, c = 5; int d = a * -(b + c); // d is -27 System.out.println(d);/*w w w. jav a 2 s .c o m*/ } }