System.out.println("foo" + s != null ? s : ""); precedence
Alexandre Petit-Bianco
apbianco@cygnus.com
Wed Aug 15 19:54:00 GMT 2001
Tom Tromey writes:
> How do we know it is a bug?
I didn't give a second thought at the operator precedence and I was
actually thinking that Sun's grammar was flawed in that respect.
On a second thought, it exhibits a behavior I've seen reported at
different place as being the correct one. Duh.
> "The Java Programming Language" (not canonical, but maybe useful)
> does have a table of operator precedence; it shows binary `+' having
> precedence over `?:'.
Yes, I think this is correct and that the PR should be closed. For
some reason the test case looked like it should print something
else. Thank you for having a look at it.
./A
More information about the Java
mailing list