This week's book giveaway is in the Agile and Other Processes forum. We're giving away four copies of Software Teaming: A Mob Programming, Whole-Team Approach and have Woody Zuill and Kevin Meadows on-line! See this thread for details.
Hanumant Deshmukh (OCAJP Associate Java 8 Programmer Certification Fundamentals 1Z0-808) wrote:In other words, almost all of the operators in Java are defined to be left-associative. The only exceptions are the assignment operators (simple as well as compound) and the ternary operator.
Hey, this is a corner (edge of an edge) case, but as Charles pointed out that Hanumant Deshmukh mentioned somewhere else, all of the compound assignment operators are right-to-left as well.
jshell> x = 0
x ==> 0
jshell> y = 2
y ==> 2
jshell> z = 3
z ==> 3
jshell> a = x += y += z;
a ==> 5.0
x ==> 5
If it were true that simple = was the only right to left binary operator, x would be == 2 there, but literally all the compound assignment operators are right-to-left as well.
I feel like at some point I've seen this tested in someone's mock exam questions somewhere.
Hopefully not on real exam questions, but good to be prepared.
RTFJD (the JavaDocs are your friends!) If you haven't read them in a long time, then RRTFJD (they might have changed!)