首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

新手!JAVA中继承有关问题!

2012-12-15 
新手求助!!JAVA中继承问题!!Java codepublic class ThreeD extends TwoD {private int zpublic ThreeD(in

新手求助!!JAVA中继承问题!!

Java code
public class ThreeD extends TwoD {     private int z;          public ThreeD(int x, int y,int z) {         super(x, y);         this.z = z;     }          public void display() {         System.out.println("这个空间点的坐标是:"+[color=#FF0000]x[/color]+","+[color=#FF0000]y[/color]+","+z);     }public class TwoD {     private int x;     private int y;      public TwoD(int x, int y) {         this.x = x;         this.y = 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 void display() {         System.out.println("这个平面点的坐标是:" + x + "," + y);     }}    public static void main(String[] args) {             TwoD Tpoint = new TwoD(4, 8);                 TwoD thpoint = new ThreeD(20,30,40);                          show(Tpoint);             show(thpoint);                  }          public static void show(TwoD c){         c.display();     }


不知道错在哪里!! 结果就是和我想象的不一样!!!

热点排行