File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Operator Precedence Mnemonic. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Operator Precedence Mnemonic." Watch "Operator Precedence Mnemonic." New topic

Operator Precedence Mnemonic.

Anthony Roy

Joined: Oct 08, 2003
Posts: 8
This is designed to not only tell you the precedence of the operations, but also how many operators at each level (count the letters in each word of the mnemonic). Well, it helped me :-):
Leave On Undies About Sad Couples Bed So TAntalizingly.
Language(5): . (method/instance invocation)
() (Parameters to a method)
[] (Array index)
-- ++ Pre inc/dec
Object(2): (cast), new
Unary(6): +,-,!,~,++,-- (post inc/dec)
Arithmetic(5): *,/,%,+,-
Shift(3): >>, >>>, <<
Comparison(7): <,>,<=,>=,==,!=, instanceof
Bitwise(3): &, ^, |
Shortcut(2): &&, ||
Ternary(1): ? :
Assignment(12): =, +=, -=, *=, %=, /=,
&=, ^=, |=, >>=, >>>=, <<=

Ant...<br /><a href="" target="_blank" rel="nofollow"></a>
Doug Dunn
Ranch Hand

Joined: Aug 03, 2003
Posts: 66
I really do not want to come off harsh, but this is an admixture of primary expressions, separators, and operators. Precedence really only applies to operators (of which there are exactly 40 in the Java programming language). Primary expressions such a method invocation and class instance creation expressions are always evaluated first. The brackets in an array index expression as well as the parentheses in a method invocation or class instance creation expression are separators, not operators. The fact that the index expression in an array creation expression is evaluated first is simply an order of evaluation question in that particular primary expression. The same is true of parameter lists. The keyword new is also not an operator, nor can it be separated from the fact that it is part of a primary expression. The use of parentheses around an operator expression makes it a primary expression that must be evaluated first, as are all primary expressions (in a left-to-right order). Besides that, mnemonics that are hard to remember are counter productive.

Download a copy of <a href="" target="_blank" rel="nofollow"><i>"Mastering The Fundamentals of The Java Programming Language"</i></a>
I agree. Here's the link:
subject: Operator Precedence Mnemonic.
It's not a secret anymore!