我尝试实现相当于Java使用typeof(SomeClass的)
Hashtable<string, -Typeof one Class->
在Java中
。但我不知道如何使这个工作。我试过
Hashtable<String, AbstractRestCommand.class>
但这似乎是错误的。
Btw。我希望这在运行时为每个反射创建一个新的类实例。
所以我的问题是,如何做这种东西。
编辑:
我有抽象类 “AbstractRestCommand”。现在我想创建有很多命令的哈希表是这样的:
Commands.put("PUT", -PutCommand-);
Commands.put("DELETE", -DeleteCommand-);
其中PutCommand和DeleteCommand延伸AbstractRestCommand,这样我就可以用
String com = "PUT"
AbstractRestCommand command = Commands[com].forName().newInstance();
...
你的意思'哈希表<字符串,AbstractRestCommand>'? – BalusC 2011-05-30 20:56:33