Post Increment (n++): It increases the value of variable by 1 after execution of the statement.
Pre Increment (++n): It increases the value of variable by 1 before execution of the statement.
Pre Increment (++n): It increases the value of variable by 1 before execution of the statement.
Program | Output |
class Demo { public static void main(String args[]) { int n=10; System.out.println(n); System.out.println(n++); System.out.println(n); } } |
10 10 11 |
Program | Output |
class Demo { public static void main(String args[]) { int n=10; System.out.println(n); System.out.println(++n); System.out.println(n); } } |
10 11 11 |
This comment has been removed by the author.
ReplyDeletegreat explanation i found one more
ReplyDeletehere
Tnx for making this as easy as pie.
ReplyDelete