Re: [問題] 關於 reflection

看板java作者 (._.)時間19年前 (2007/04/05 23:37), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
==站內信件== ※ 引述《loveflames (.....)》之銘言: : 那個網站之前已經去過了 ^^^^^^^^^^ : 一開始是用object_name.getClass().getName() : 可是物件不是都要先預設類別嗎? : 這樣不是變成了要先知道有什麼檔 : 而不能用字串來直接設定物件類別? ^^^^^^^^^^^^^^^^^^^^^^^^ 這篇好一些, ┌─────────────────────────────────┐ │Method Summary │ ├───────┬─────────────────────────┤ │ static Class │ forName(String className) │ │ │ Returns the Class object associated with the│ │ │ class or interface with the given string name. │ ├───────┼─────────────────────────┤ │ Object│ newInstance() │ │ │ Creates a new instance of the class │ │ │ represented by this Class object. │ └───────┴─────────────────────────┘ 想必你沒看到這一段? 想必 forName 只拿到 Class 你不夠用, newInstance 我也附上來了. -- 置底文不是沒有寫站內跟看板的差別, 也不是沒有寫這是個轉信版. 到底有哪邊看不懂, 有人寫信給我說嘛? 沒有. 有人寫在板上說要怎麼改嗎? 沒有. 這樣最好我是知道怎麼去幫那些"初學者"啦. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.25.148.49
文章代碼(AID): #165HUt_H (java)
文章代碼(AID): #165HUt_H (java)