Created
April 22, 2019 02:08
-
-
Save kedarmhaswade/59192a790981738e1489c3fa165055cb to your computer and use it in GitHub Desktop.
A method call expression results in a value, not an automatic variable (that should appear on the lhs of an assignment statement)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ValueIsNotVariable { | |
static int get() { | |
return 10; | |
} | |
static void inc() { | |
get() += 1; | |
} | |
} | |
/** | |
➜ Java javac Assign.java | |
Assign.java:6: error: unexpected type | |
get() += 1; | |
^ | |
required: variable | |
found: value | |
1 error | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment