我的节点类是
class Node{
protected int data;
protected Node link;
public Node(){
link=null;
data =0;
}
public Node(int d,Node n){
data=d;
link=n;
}
public void setlink(Node n){
link=n;
}
public void setData(int d){
data=d;
}
public Node getlink(){
return link;
}
public int getData(){
return data;
}
}我想要创建一个包含5个部分的节点:
发布于 2016-03-01 07:40:11
可以使用以下类作为具有所需值的节点:
static class Node
{
int rowNo;
int columnNo;
int value;
Node next;
int nextColumnNo;
Node(int r,int c,int v)
{
rowNo=r;
columnNo=c;
value=v;
next=null;
nextColumnNo=0;
}
}并将节点链接到一起,如下所示:
head = new Node(1,11,11);
Node second = new Node(2,22,22);
Node third = new Node(3,33,33);
head.next=second;
second.next=third;
head.nextColumnNo = second.columnNo;
second.nextColumnNo = third.columnNo;https://stackoverflow.com/questions/35716998
复制相似问题