Re: Looking for good table with all Java operators
Robbo wrote:
Your table is good piece of work. Much better than many
incomplete tutorials which may be found all over the internet.
But, if I am right, a few hours ago there was no information
about "new". Probably you have added it not more than
a few hours ago.
Where did you find information that "new" is officially
operator in Java? I am really interested in this topic.
It is not. The keyword 'new' is officially not an operator in Java.
Patricia Shanahan (in this thread) has said that "new" is not an
operator. I have not found any information that would confirm
that "new" is an operator in JLS (3rd edition).
That's because 'new' is not an operator in the JLS (any edition), ergo
in the Java language.
As Patricia also pointed out, the JLS defines the language, therefore
there is no higher authority.
Mike Schilling wrote:
"Operator" means different things to different people. A parser guy
would probably call "new" an operator; because it combines expressions
into a more complex expression and has a defined precedence. But the
"offical" list of operators is found at
<http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.12>
This link has been posted before in this thread. OP: you should read
it.
and doesn't include cast, new, or parentheses.
nor "dot". However, the JLS does refer to 'instanceof' as an
operator.
This question has now been answered several times in this thread. You
might want to consider accepting the answer.
Robbo wrote:
And the second thing. In your table there is (cast) operator
at precedence of 1 (it has the same priority as prefix and unary
operators). Also association is "Right".
Don't you mean "associativity"?
If I am right (byte)++x means that ++ is computed before (byte)
-- both (cast) and prefix ++ have the same priority and association [sic=
]
is "Right".
And in (byte)x++, (byte) is first because of higher priority of
cast than postfix ++.
What do you think?
Mike Schilling wrote:
Other way around. Postfix ++ has a higher precedence than the cast
does.
I believe the issue here is one of associativity, not precedence.
Both cast and postfix operators are right-associative, therefore the
postfix operator is evaluated first.
The precedence is indicated by the order in which the operators and
other expressions (e.g., cast expressions) appear in chapter 15 of the
JLS.
<http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html>
and is defined by the productions in
<http://java.sun.com/docs/books/jls/third_edition/html/
syntax.html#18.1>
--
Lew