Valentin Musoiu wrote:Hey, Andreas.
It is not unusual. It is just a matter of forward referencing.
Forward referencing means reading a variable before declaring it, and is illegal. Why? To prevent circular assignments like:
Valentin Musoiu wrote:Hi, Andreas.
I'm so sorry for this late reply. Been awfully sick and then I forgot about my post
This time I cannot but state my own opinion on this matter.
I think restrictions are introduced in a language to help developers with errors that can easily be done, not to make the language idiot-proof.
In my opinion it is easy to make a mistake like the first (especially if there is a lot of code between the 2 statements).
As for the latter, if you put "this." in front of the variables, then you probably are aware of the implications of your actions. Although I still cannot find a valid reason why would you want to do that...
Once again, this is only my opinion. For more details, you will probably have to contact Gosling himself
2: The static initializers are then executed top-to-bottom, together with the static variable declarations. If the variable declarations include an initialization value, that value is assigned, overriding the previously assigned value; be it the default value, or any value assigned to the variable in a static initialization block textually prior to the variable declaration (like the cases we've discussed in this thread).
- If the declaration does NOT include an initialization value, the latest assigned value (either the default value or, if it exists, the value given in a previously executed static initializer) is retained after the variable declaration.
I think you are wrong about this topic. The latest value assigned to a member seems to be the init block one (if exists). If not, the assigned value will be the one that appears in the member declaration (or the default value, of there is no assigned value). You can easily check what I say by running this code:
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton