O
Oliver Wong
I'm reading the JLS 3rd edition and section 15.14.2 has this statement:
http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.14.2
<quote>
A variable that is declared final cannot be incremented (unless it is a
definitely unassigned (§16) blank final variable (§4.12.4))
</quote>
I did not understand the "unless" part, and I tried various ways to
write code in Eclipse that would increment a final variable (e.g. by not
initializing it, etc.) but nothing I could produce was without compile
errors.
So I'm wondering, what did Sun mean by this statement? Under what
conditions could one increment a final variable?
- Oliver
http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.14.2
<quote>
A variable that is declared final cannot be incremented (unless it is a
definitely unassigned (§16) blank final variable (§4.12.4))
</quote>
I did not understand the "unless" part, and I tried various ways to
write code in Eclipse that would increment a final variable (e.g. by not
initializing it, etc.) but nothing I could produce was without compile
errors.
So I'm wondering, what did Sun mean by this statement? Under what
conditions could one increment a final variable?
- Oliver