public class INode
{
private int value;
private INode right, down;
private int row, col;
public INode(int value)
{
this.value = value;
}
public int getValue()
{
return value;
}
public void setValue(int value)
{
this.value = value;
}
public INode getRight()
{
return right;
}
public void setRight(INode right)
{
this.right = right;
}
public INode getDown()
{
return down;
}
public void setDown(INode down)
{
this.down = down;
}
public int getRow()
{
return row;
}
public void setRow(int row)
{
this.row = row;
}
public int getCol()
{
return col;
}
public void setCol(int col)
{
this.col = col;
}
}
我可以得到 a = 8 的值,但是对于 head,即使我使用构造函数进行设置,仍然给我 value = null ......不知道为什么。
司机是:
import java.util.*;
public class List
{
public static INode head;
public List()
{
head = new INode(8);
}
public static void main (String[] args)
{
INode a = new INode(8);
int data = a.getValue();
System.out.println(data);
System.out.println(head.getValue());
}
}
请帮我一把。不明白为什么当我使用构造函数时,我无法将值分配给节点,但是当我创建实例时,我可以......
谢谢各位,爱你们!很大的帮助!