package cn.classes;
public class oneclass
{
}
package cn.test;
import cn.classes.oneclass;
public class test
public static void main(string[] args)
{
class<?> c1 = null;
class<?> c2 = null;
class<?> c3 = null;
try
{
// 重要
c1 = class.forname("cn.classes.oneclass");
}
catch (classnotfoundexception e)
e.printstacktrace();
c2 = new oneclass().getclass();
c3 = oneclass.class;
// 结果cn.classes.oneclass
system.out.println(c1.getname());
system.out.println(c2.getname());
system.out.println(c3.getname());
}
帮助文档参见
java.lang;
java.lang.reflect