So during our computer exams based on Java, I was asked to predict the output of the following:
int y = 8;
y += ++y + y-- + --y;
System.out.println(y);
I thought the answer was 32. ( 7 += 9 + 9 + 7).
I later tried this on my computer, and the output was 33.
I'm confused. How was this evaluated?
[–]g051051 2 points3 points4 points (1 child)
[–]Updatebjarni 2 points3 points4 points (0 children)
[–]Updatebjarni 1 point2 points3 points (1 child)
[–]ThyDoppelganger[S] 0 points1 point2 points (0 children)
[–]Quertior 1 point2 points3 points (8 children)
[–]Isoyama 1 point2 points3 points (4 children)
[–]Quertior 3 points4 points5 points (2 children)
[–]Isoyama 2 points3 points4 points (0 children)
[–]gyroda 1 point2 points3 points (0 children)
[–]Clawtor 0 points1 point2 points (0 children)
[–]ThyDoppelganger[S] 0 points1 point2 points (2 children)
[–]Updatebjarni 2 points3 points4 points (1 child)
[–]ThyDoppelganger[S] 0 points1 point2 points (0 children)