java code問題

我想問以下的code有什麼問題?

希望能提供正確答案

public class Point{

int x,y;

String name;

public string toString(){

return name + " = C " + x + "," + y + ")";

public Point (String name, int x, int y){

this.name = name;

set(x,y);

public void set (int x,int y){

this.x=x;

this.y=y;

}

接著下面↓

更新:

public void main(String[] args){

point start = new point ("start",1,1);

point end = new point ("end",10,10);

System.out.println(start.toString());

point stray = end;

System.out.println(stray.toString());

更新 2:

end.y=100;

system.out.println(stray.toString());

end = new point("end 2",50,50);

stray.x=200;

System.out.println(stray.toString());

System.out.println(start.toString());

System.out.println(end.toString());

}

}

}

}

1 個解答

評分
  • 1 十年前
    最愛解答

    有D語法錯誤.

    (1) 你個class係Point (大楷P), 所以定義(define)變數(variable)同埋new時唔可以用 point (細楷p).

    (2) Curly Bracket ("}") 放錯位.

    (3) 你想個class係command prompt行到, 係 public static main, 唔係 public main

    請看這個: http://www.badongo.com/file/3544694

還有問題嗎?立即提問即可得到解答。