廣告廣告
  加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 2376 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為IE收藏   收藏主題   上一主題 | 下一主題   
s9005034 手機
個人文章 個人相簿 個人日記 個人地圖
初露鋒芒
級別: 初露鋒芒 該用戶目前不上站
推文 x0 鮮花 x14
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片
推文 x0
[Java] Inner class 的問題?
class InnerSuper{protected int x=1;}
class OuterSuper{protected int y=2;}
interface ForPolymor{void f();}
class Test extends OuterSuper{
private int z=3;
public ForPolymor g(){
final int i=4;
int j=5;
class Inner extends InnerSuper implements ForPolymor{
int k=6;
public void f(){
int m=7;
System.out.println(x);//因為In ..

訪客只能看到部份內容,免費 加入會員 或由臉書 Google 可以看到全部內容



獻花 x0 回到頂端 [樓 主] From:台灣中華電信 | Posted:2005-08-01 11:02 |
PeterPan 手機
個人文章 個人相簿 個人日記 個人地圖
特殊貢獻獎 社區建設獎
知名人士
級別: 知名人士 該用戶目前不上站
推文 x1 鮮花 x99
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片

定義於某 class 的某個 method 內的 inner class,稱為 local inner class,性質跟區域變數一樣,只能在該 method 內使用,無法在其他地方直接建立其 object。
local inner class 只能取用外部 class 中,以 final 宣告的變數。
ForPolymor fp=t.g(); ←﹝由於g()這個 method 的回傳型別為 ForPolymor,注意看它最後三行的程式碼為Inner in=new Inner(); in.f(); return in; 所以這樣寫就能接到該 local inner class 的 object,接下來才能呼叫該 class 的 f() method﹞

=以上若有謬誤請大力糾正=


神:在多項技術領域,具有不可取代性且擁有高度權威
魔:在某項技術領域,具有不可取代性且擁有高度權威
妖:有高度實戰經驗,且在專業領域上具有domain-Knowledge
俠:在技術層面上有過人專業能力
人:可以獨立運作、設計暨開發系統
蟲:coder only (my level)
獻花 x0 回到頂端 [1 樓] From: | Posted:2005-08-05 17:03 |

首頁  發表文章 發表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.012800 second(s),query:16 Gzip disabled
本站由 瀛睿律師事務所 擔任常年法律顧問 | 免責聲明 | 本網站已依台灣網站內容分級規定處理 | 連絡我們 | 訪客留言