I am preparing Java grammar for my parser generator. Noticed that statements like "(x) = 5 ;" where x is an "int" compile and execute correctly, but cannot see that Java Language Specification allows "(x)" as left hand side. Am I missing something?
The double colon (::) operator, also known as method reference operator in Java, is used to call a method by referring to it with the help of its class directly. They behave exactly as the lambda expressions.
In an assignment statement, the value of the right-hand side is assigned to the left-hand side. The left-hand side must be a variable, property, or indexer. To fix this error, make sure that all operators are on the right-hand side and that the left-hand side is a variable, property, or indexer.
We use the symbol || to denote the OR operator. This operator will only return false when both conditions are false. This means that if both conditions are true, we would get true returned, and if one of both conditions is true, we would also get a value of true returned to us. Let's go over a few examples.
The following part of the JLS should be the relevant one :
15.8.5. Parenthesized Expressions
If the contained expression denotes a variable then the parenthesized expression also denotes that variable.
Which means (x)
is equivalent to x
, x
being an expression by itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With