Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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