• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Operator Precedence Mnemonic.  RSS feed

Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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): =, +=, -=, *=, %=, /=,
&=, ^=, |=, >>=, >>>=, <<=
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!