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 post/prefix increment operator in java program

class apincrement
public static void main (String arg[])
int a=15,b=34;
int d,e;
System.out.println ("\n\t a = "+a);
System.out.println ("\n\t b = "+b);
System.out.println ("\n\t d = "+d);
System.out.println ("\n\t e = "+e);

         When you will execute this program you will see that values of 'a' , 'b' and 'd' are increased by 1 but value of 'e' is same as we initialized it by 34. The reason behind this is we are using post fix increment operator. In case of post fix increment value of the variable is used first and then it is increased by 1.


No comments:

Post a Comment