Re: [問題] extends inner class

看板java作者 (Alien)時間16年前 (2009/06/10 16:58), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
※ 引述《sansea (痕天)》之銘言: : 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 : 請多指教 Point 有需要是 non-static 的 inner class 嗎? 沒有需要的話, 改為 static 就好了. 另外 visibility 也可能會有問題, 改為 public 比較好 (這個視乎情況) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 202.155.236.82
文章代碼(AID): #1ABtMnoZ (java)
文章代碼(AID): #1ABtMnoZ (java)