Oct 5, 2012

Pre and Post Increment Operator in Java

         In Java we have pre and post increment operator .. Pre increment will increase the value at the start and take the value. Post Increment will take the value and increment it.
For instance,
 if a=5;  a++ and ++ a will be printed as 5 and 6 receptively finally the value of a will be 6 for a.
       Now lets play a game with a logic. If you understand the above mentioned elementary part, then you can win this game easily.
 int a =3;
int k= a++ + a++ + ++a;
Whats the value of k ?
..
..
k=13, try it out.    k= 3 + 4 + 6=13 and a=6.
People also visited  String To Byte Array And Byte Array To String Code In Java   Creating JAR File Using Eclipse IDE    Accessors And Mutators In JAVA

No comments:

Post a Comment

Post a Comment

Note: Only a member of this blog may post a comment.