Some points here:1) You don't normally make direct use of ClassLoader, unless you wanna customize the security/access/initialization mechanism of the default class loaders provided.
2) To use java.lang.Class to load a class, simple do this:
try {
Class cls = Class.forName("MyClass");
Object obj = cls.newInstance();
} catch (....) {
}
//There is a long list of possible exceptions here. Check JDK API doc for the list.
终於盼到希望了
不过想问一下:obj是Object,并不是我的MyClass,用obj来调用MyClass的method很显然找不到的,这个怎么办?如果还要用(MyClass)obj的话那岂不是还要hard coding?
爱惜无俸禄 糟蹋有乾坤