I just noticed that you can do System.out.println(FooObject.fooNumber = 4); which will assign 4 to fooNumber and also output the value 4. Why does it output FooNumber after the assignment?
Also, the rules of precedence state that the assignment occurs first but nothing about whether the print occurs first or the assignment. Am I right? So why doesn’t the previous value get printed first and then the assignment? As I know, subexpressions are evaluated left to right in Java, so does this apply here?
I just noticed that you can do System.out.println(FooObject.fooNumber = 4); which will assign 4
Share
It’s because expressions like
a = bhave type ofaand value ofa, after assignment. This statement is recursive, soa = b = cand others are also the same.