class Node{
private int x;
private int y;
private int d;
public Node(){
}
public Node(int x,int y){
x=this.x;
y=this.y;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int getD() {
return d;
}
public void setD(int d) {
this.d = d;
} public static void main(String[] args) {
LinkedList<Node> s=new LinkedList<Node>();
Node no=new Node(4,7);
Node n2=new Node(5,6);
Node n3=new Node(6,7);
s.push(no);
s.push(n2);
s.push(n3);
while(!(s.isEmpty())){
Node e=(Node)s.pop();
System.out.println(e.getX()+","+e.getY());
}
}
}
public Node(int x,int y){
x=this.x;
y=this.y;
}无语了,看看你的构造方法,
x=this.x;
y=this.y;
不是0就怪了
把public Node(int x,int y){
x=this.x;
y=this.y;
}
改成public Node(int x,int y){
this.x=x;
this.y=y;
}就可以了啊....
y=this.y;呵呵,你是把哪个赋值给哪个啊