Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我可能被误解了,我想创建对象并使用字符串指定对象是哪个类。
是的,您可以为此使用反射。
要上课,请使用
// if your class is in package com.foo and is named Bar Class<?> klass = Class.forName("com.foo.Bar");
阅读教程以获取更多详细信息。