PROGRAM:
To show use of decrement operator.
/**
* @Prof. Jayesh
* Decrement operator uses ‘ – ‘.
*/
public class DecrementOperator
{
public static void main(String args[])
{
int a=10,b=20;
a–;
–b;
System.out.println(“a = “+a);
System.out.println(“b = “+b);
System.out.println(“a+b = “+(a+b));
System.out.println(“a– = “+(a–));
System.out.println(“a– = “+(a–));
System.out.println(“a = “+a);
System.out.println(“–a = “+(–a));
System.out.println(“–a = “+(–a));
System.out.println(“–a = “+(–a));
System.out.println(a);
}
}
OUTPUT:
a
= 9
b
= 19
a+b
= 28
a–
= 9
a–
= 8
a
= 7
–a
= 6
–a
= 5
–a
= 4
4