Skip to content

Instantly share code, notes, and snippets.

@kedarmhaswade
Created April 22, 2019 02:08
Show Gist options
  • Save kedarmhaswade/59192a790981738e1489c3fa165055cb to your computer and use it in GitHub Desktop.
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)
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