About Question com.enthuware.jfcja.v8.2.402 :
Posted: Tue Nov 16, 2021 4:29 am
Hello,
I don't understand what is Node node; in this code. Is this an instance variable of type Node?
But why should have an object an instance variable of the same type as the object itself?
I don't understand what is Node node; in this code. Is this an instance variable of type Node?
But why should have an object an instance variable of the same type as the object itself?
Code: Select all
class Node{
int id;
Node node;
public static void main(String[] args) {
Node n = new Node();
System.out.println(n.id);
System.out.println(n.node.id);
}
}