I have a doubt JLS 15.14.1 says the result of the postfix expression must be a variable of a numeric type, or a compile time error occurs. JLS 15.15.1 says
the result of prefix increment expression is not a variable, but a value.
what exacly does it signify. I thought that it would be possible to do something like x++ = y ( because result of x++ is a variable) but it doesnt work like that.
If you look at the entire first paragraph of 15.14.1 and the entire first paragraph of 15.15.1, you find that they are nearly identical - the only difference is that the word "prefix" is replaced with "postfix". You are comparing two quotes from different positions in the paragraphs, without looking carefully at the exact wording. No need to look at two different sections to get those sentences - you can find nearly the same sentences you cited within the same paragraph at the beginning of 15.14.1
A postfix expression followed by a ++ operator is a postfix increment expression. The result of the postfix expression must be a variable of a numeric type, or a compile-time error occurs. The type of the postfix increment expression is the type of the variable. The result of the postfix increment expression is not a variable, but a value.
The key difference between the two sentences in red is that the first refers to a posfix expression, while the second refers to a postfix increment expression. Look again at the very first sentence of the quote - those are two different things. In the case of "x++", "x" by itself is a postfix expression, and "x++" is a postfix increment expression. So "x" must be (and is) a variable of numeric type, and "x++" is not a variable, but a value. Clear?
[This message has been edited by Jim Yingst (edited November 10, 2000).]
Jim I removing my rattling post in the light of what you have said. Subha
mohit joshi
Ranch Hand
Joined: Sep 23, 2000
Posts: 243
posted
0
Well first of all let me thank you for clearing my doubt. I had posted the same question on certification forum but nobody noticed it. I must admit that I was not very careful while reading that section. But my longstanding doubt has been cleared, so I must thank Jim again.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.