First, a puzzle: What does the following code print?
public class RecursiveStatic {
public static void main(String[] args) {
System.out.println(scale
Not a bug.
When the first call to scale
is called from
private static final long X = scale(10);
It tries to evaluate return X * value
. X
has not been assigned a value yet and therefore the default value for a long
is used (which is 0
).
So that line of code evaluates to X * 10
i.e. 0 * 10
which is 0
.