Page 1 of 1
					
				[HD Pg 129, Sec. 5.1.6 - precedence]
				Posted: Thu Jan 24, 2019 8:01 pm
				by OCAJO1
				Looking at the table of precedence on page 130,
postfix  expr++, expr-
unary   ++expr, --expr, +expr, -expr, ~, !
How come in Java postfix has higher precedence than prefix?
Thanks
			 
			
					
				Re: [HD Pg 129, Sec. 5.1.6 - precedence]
				Posted: Thu Jan 24, 2019 8:15 pm
				by admin
				Not sure I understand your question. It is the decision of the language designers.
			 
			
					
				Re: [HD Pg 129, Sec. 5.1.6 - precedence]
				Posted: Fri Jan 25, 2019 12:25 pm
				by OCAJO1
				Oh I figured as much. I just was wondering if there was "as you always say about Java conventions" a logical reasoning behind their decision 

 
			 
			
					
				Re: [HD Pg 129, Sec. 5.1.6 - precedence]
				Posted: Fri Jan 25, 2019 12:34 pm
				by admin
				They most likely had a valid reason for it but I haven't seen it documented anywhere. I guess, they continued with the existing "convention" in this case.
			 
			
					
				Re: [HD Pg 129, Sec. 5.1.6 - precedence]
				Posted: Mon May 06, 2019 3:04 am
				by flex567
				This is the example you provided for explaining precedence:
The Cast operator is in the precedence table, but Parentheses are not in you precedence table nor the Parentheses are explained in the 5 chapter - Using Operators.
At least not in the tables in the chapter 
5.1.1 Overview of operators available in Java
 
			 
			
					
				Re: [HD Pg 129, Sec. 5.1.6 - precedence]
				Posted: Mon May 06, 2019 5:32 am
				by admin
				Because parentheses are not operators as such. They change the precedence of the components of an expression just like the mathematical expressions as mentioned at the start of the section. The book assumes you know BODMAS principle (from mathematics).  For example, 2 + 6/2 is 5 but and (2+6)/2 is 4.
On page 131, the book says, 
You can use parentheses to change how the terms of an expressions are grouped if the default grouping based on precedence and associativity is not what you want. The usage of parentheses for this purpose is fairly standard so I will not be discussing it any further.
 
			 
			
					
				Re: [HD Pg 129, Sec. 5.1.6 - precedence]
				Posted: Wed Jun 19, 2019 2:22 pm
				by Username987654
				will be grouped as a = ( b = (c = 5) ;
The parenthesis aren't matching.
 
			 
			
					
				Re: [HD Pg 129, Sec. 5.1.6 - precedence]
				Posted: Thu Jun 20, 2019 9:18 pm
				by admin
				Correct. Added to errata.
thank you for your feedback!
			 
			
					
				Re: [HD Pg 129, Sec. 5.1.6 - precedence]
				Posted: Wed Jul 21, 2021 12:27 pm
				by enthunoob
				What could be a reason that (cast) has the (almost) highest precedence?