定義一個新類“Point”,包含兩個整型欄位成員“x”和“y”。這個怎么搞?求大佬回答。
uj5u.com熱心網友回復:
今天開學么,這么都是問很基礎的東西啊,這個一般書上都有吧!
public class Point {
int x,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 Point(int x, int y) {
super();
this.x = x;
this.y = y;
}
}
uj5u.com熱心網友回復:
public static class Point{private static int x;
private static int y;
public static int getX(){
return x;
}
public static int getY(){
return y;
}
}
uj5u.com熱心網友回復:
不要隨便用靜態,這是不好的習慣。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/149164.html
標籤:Java相關
