First, a puzzle: What does the following code print?
public class RecursiveStatic {
public static void main(String[] args) {
System.out.println(scale
Nothing to do with final here.
Since it is at instance or class level, it holds the default value if nothing gets assigned yet. That is the reason you seeing 0
when you accessing it without assigning.
If you access X
without completely assigning, it holds the default values of long which is 0
, hence the results.