Re: [問題] 關於 reflection
==站內信件==
※ 引述《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
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):