作者sansea (痕天)
看板java
標題[問題] extends inner class
時間Wed Jun 10 16:43:08 2009
public class Circle {
class Point {
public int x = 5, y = 2;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public String toString() {
return x + ", " + y;
}
}
}
public class Test extends Circle.Point {
public Test() {
System.out.println(toString());
}
}
compile的時候出現這個錯誤
Test.java:2: an enclosing instance that contains Circle.Point is required
public Test() {
^
1 error
請問是無法繼承inner class嗎?
新手JAVA首PO
請多指教
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.120.210.186
推 Fenikso:Test()的第一行加上 new Circle().super(1, 2); 06/10 22:11
→ Fenikso:non-static inner class需要一個outer class的instance 06/10 22:12