Search This Blog

If you have any problem or question please write in the comments. We will try to solve and send you the solution. Not just that we will also post your problems solution on our blog.

Monday, 13 June 2011

Using psot/prefix decrement operator in java program


class apdecrement
{
public static void main (String arg[])
{
int a=97,b=23;
int c,d;
c=--a;
d=b--;
System.out.println ("\n\t a = "+a);
System.out.println ("\n\t b = "+b);
System.out.println ("\n\t c = "+c);
System.out.println ("\n\t d = "+d);
}
}


Note:
          After executing this program you will see the decrement in the values of 'a' , 'b' and 'c' but value of 'd' will as it is. Just like post fix increment increases value after it is used, post fix decrement also do so but it decreases the value by 1 after it is used.

No comments:

Post a Comment