I have the following piece of code-
{s = "Hello";}
String s;
This compiles fine, implying that the variable definitions are executed before the instance blocks. However, if I use the following code instead, it does not compile ("error: illegal forward reference").
{s = "Hello"; String ss = s;}
String s;
So it is not possible to use the value of 's' on the right-hand side of a statement in an instance block that comes BEFORE the variable definition. Is there a sane explanation of what is happening behind the scenes, or is this simply an idiosyncratic feature of Java?
P.S. I have seen a similar question asked before, the only explanation given there is that it is a feature of Java. I am writing this to ask the community if that is indeed the final word on this question.