阿薩布魯‧湖瀾
2006-09-11 07:37:13 UTC
============================================================
class B extends A{
private int x,y;
B(int x, int y){
this.x=x;this.y=y;}
void printXY(){System.out.print("B: x=" + x + ", y=" + y);}
public static void main(String[] args){
A t = new B(1,2);
t.printXY();}
}
class A{
private int x,y;
A(int x, int y){
this.x=x;this.y=y;}
void printXY(){System.out.print("A: x=" + x + ", y=" + y);}
}
=============================================================
上面的程式碼為什麼會產生找不到class A的Constructor的compile error?
不是應該會有 Default Constructor 嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.225.190.55
class B extends A{
private int x,y;
B(int x, int y){
this.x=x;this.y=y;}
void printXY(){System.out.print("B: x=" + x + ", y=" + y);}
public static void main(String[] args){
A t = new B(1,2);
t.printXY();}
}
class A{
private int x,y;
A(int x, int y){
this.x=x;this.y=y;}
void printXY(){System.out.print("A: x=" + x + ", y=" + y);}
}
=============================================================
上面的程式碼為什麼會產生找不到class A的Constructor的compile error?
不是應該會有 Default Constructor 嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.225.190.55