I noticed a surprising behaviour.
I can write so:
Integer integer = 0;
integer++;
But I cannot write so:
getInteger()++;
Here's my getInteger()
method:
public static Integer getInteger(){
return 0;
}
For me, two snippets look the same.
But the second piece of code returns an error:
unexpected type
getInteger()++;
^
required: variable
found: value
Why is the second construction forbidden?
Often, I feel forced to write "ugly" code like this:
obj.set(obj.get()+1);
It looks redundant.