假设我有一个节点类型。
public class Node{
private Node next;
private int data;
// other methods including constructor and setting next reference.
}
或者像下面这样使用 null
表示未初始化的值:
public class Node{
private Node next = null;
private int data;
}
next = null
和data = 0
。无需显式设置它们。 - Seelenvirtuose