Skip to content
Advertisement

Tag: postfix-operator

Why does jshell show this number?

I am learning java and this logic makes me feel confused. Isn’t here i=20(+1)+20(+1)? Why 41 instead of 42? See this code run at Ideone.com. Answer Effectively, the expression i=i++ + i++; is equal to i=i++ + i;. Why? The latter i++ result value is never used and is not propagated. The result of the postfix addition i++ is used

Advertisement