作者ogamenewbie (._.)
站内java
标题Re: [问题] 关於 reflection
时间Thu Apr 5 23:37:26 2007
==站内信件==
※ 引述《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