Can anyone summarize the associativity rules for all the operators in Java?

For example, I fail to understand why boolean c = a == b == true returns true(assuming a is equal to b).

So if anyone can give me a good summarization of all the minute rules to be followed when evaluating operators in java would be of really help to me.

Regards,

Jothi Shankar Kumar. S

[ October 16, 2006: Message edited by: Jothi Shankar Kumar Sankararaj ]

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master

Did a rm -R / to find out that I lost my entire Linux installation!

OPERATOR PRECEDENCE

P-ost-fix Operators [] . (parameters) expression++ expresion--

P-efix Unary Operators ++expression --expression

O-bject creation and cast new (type)

M-ultiplication * / %

A-ddition + -

S-hift << >> >>>

R-elational Operators < <= > >= instanceof

E-quality Operators == !=

B-itwise/boolean AND &

-itwise/boolean XOR ^

-itwise/boolean OR |

L-ogical AND &&

-ogical OR | |

C-onditional Operator ?:

A-ssignment = += -= *= /= %= <<= >>= >>>= &= ^= !=

[ October 16, 2006: Message edited by: Aniket Patil ]

SCJP 5.0 | SCWCD 1.4 <br /> <br />If you don't know where you are going, any road will take you there!

I did not ask for the precedence rules but rather on how to associate multiple operators? Please anyone can get this for me?

Regards,

Jothi Shankar Kumar. S

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master

Did a rm -R / to find out that I lost my entire Linux installation!

To start with, Associativity rules are used to determine which operaor should be applied first if there are two operators of the same precedence.

So what all operators fall under the left associativity rule and what all fall under the right associativity rule?

Regards,

Jothi Shankar Kumar. S

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master

Did a rm -R / to find out that I lost my entire Linux installation!

The operators *, /, and % are called the multiplicative operators. They have the same precedence and are syntactically left-associative (they group left-to-right).

The operators + and - are called the additive operators. They have the same precedence and are syntactically left-associative (they group left-to-right).

The shift operators include left shift <<, signed right shift >>, and unsigned right shift >>>; they are syntactically left-associative (they group left-to-right).

The equality operators are syntactically left-associative (they group left-to-right)

The bitwise operators and logical operators include the AND operator &, exclusive OR operator ^, and inclusive OR operator |. These operators have different precedence, with & having the highest precedence and | the lowest precedence. Each of these operators is syntactically left-associative (each groups left-to-right).

The &&, & is syntactically left-associative (it groups left-to-right).

The ||, | is syntactically left-associative (it groups left-to-right).

Expressions with unary operators group right-to-left.

The assignment operators are syntactically right-associative (they group right-to-left).

[ October 17, 2006: Message edited by: Aniket Patil ]

SCJP 5.0 | SCWCD 1.4 <br /> <br />If you don't know where you are going, any road will take you there!

Your definition lacks essence. Can you please elaborate. I guees you have missed something.

Regards,

Jothi Shankar Kumar. S

Did a rm -R / to find out that I lost my entire Linux installation!

Thanks for the explanation. By the way, how to remember these precedence rules?Is there any logic behind it so that we can remember it always?

Regards,

Jothi Shankar Kumar. S

Did a rm -R / to find out that I lost my entire Linux installation!

Can anyone say if there is a good way to remember the precedence of operators?

Regards,

Jothi Shankar Kumar. S

Did a rm -R / to find out that I lost my entire Linux installation!

Consider Paul's rocket mass heater. |