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());
}
}

}

解决方案 »

  1.   


    public Node(int x,int y){
            x=this.x;
            y=this.y;
    }无语了,看看你的构造方法,
    x=this.x;
    y=this.y;
    不是0就怪了
      

  2.   

    你看看你的this用法真的不是0才怪基础啊。。认认真真看一次书就解决啦。。很小的问题
      

  3.   

    lz是大哥还是大姐啊?这种错误都犯?
    把public Node(int x,int y){
            x=this.x;
            y=this.y;
    }
    改成public Node(int x,int y){
            this.x=x;
            this.y=y;
    }就可以了啊....
      

  4.   

            x=this.x;
            y=this.y;呵呵,你是把哪个赋值给哪个啊