Talk:Final (Java)
![]() | Java Start‑class Mid‑importance | |||||||||
|
This page was all wrong about final variables.
First, they are not like "const" in C++ since in that language a const field is limited not only to not being reassigned, but there is the additional limitation that only const methods can called on it and it can only be passed as the const argument of other methods.
Second, (non-static) inner classes can freely access any field of the enclosing class, final or not.
Final Local Variables and Arguments
Arguments and local variables can also be declared final. I'm not entirely sure how it works, but I think it should be included in this article.
Thejoshwolfe (talk) 07:53, 21 November 2008 (UTC)
- the same applies to local variables (and function arguments) as to class fields: They must be assigned to at most once (and must be assigned to before being used). Arguments are already assigned when the function body entered. 78.102.120.26 (talk) 06:53, 5 March 2009 (UTC)
Blank final
Anybody want to add something about blank finals? Otherwise I'll add it at the end of next week when I will have a lot more time.Smallman12q (talk) 02:08, 4 July 2010 (UTC)