| Author |
Precedence of operators
|
Anto Telvin
Ranch Hand
Joined: Aug 12, 2008
Posts: 113
|
|
hi all what is the difference between left to right associative and right to left associative with eg: thanks
|
Anto Telvin Mathew<br />Many of the life failures are people who did not realize how close they were to success when they give up. EDISON
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16815
|
|
Left to Right means that the evaluation is done left to right. For example, 2+3+4 -- obviously, Java can't do both additions at the same time, and they have the same precedence. It is however, left to right, so the left addition is done first. Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32833
|
|
. . . And right to left means that if you have . . . myBoolean ? 123 : otherBoolean ? 345 : 567 . . . where both the ?: operators have the same priority but associate to the right, the compiler evaluates the bit on the right (345 or 657) before offering that result as an alternative to the bit on the left (123).
|
 |
Anto Telvin
Ranch Hand
Joined: Aug 12, 2008
Posts: 113
|
|
|
thanks
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32833
|
|
You're welcome
|
 |
 |
|
|
subject: Precedence of operators
|
|
|