Click here to Skip to main content
15,878,430 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
public class Test {
int i;
int j;

public static void main(String[] args) {

Test t1 = new Test();
Test t2 = new Test();


System.out.print(t1.j++ + " " + t2.i--);

Member 11228096 12-Nov-14 10:38am    
Need help wrt the o/p of the above prgm ? when I compile it the answer is 5 5 . Need help in understanding how t1.j++ is 5

See[^], and work through it, all the answers can be found there.
Share this answer
Because x++ is what's called a "postfix" operator: it means "get the value of x and then increase x by one but do not affect the value you fetched earlier":
int temp = x;
x = x + 1;
return temp;
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900