In variable NIL is first set to null , and then initialized once from top to bottom. This is not a function and is not defined recursively. Any static field that you use before its initialization has a default value, and your code is the same as
public static Node { public static Node NIL; static { NIL = new Node(null , null ); } public Node(Object one, Object two) {
It is no different from writing
NIL = null; // set implicitly NIL = new Node(NIL, NIL);
If you define a function or method like this, you will get a StackoverflowException
Node NIL(Node a, Node b) { return NIL(NIL(a, b), NIL(a, b)); }
Peter Lawrey Jan 30 '17 at 9:44 on 2017-01-30 09:44
source share