日期:2014-05-20  浏览次数:20700 次

我是新手,求高手解疑,谢谢了
我是新手,求高手解疑,谢谢了


package chengengsheng4;

public class ClassTest1
{
  public static void main(String[] args) throws Exception
  {
  Class<?> c = Class.forName("Person1");
  }
}

class Person1
{

}
[color=#FF0000][/color]
  报错: Exception in thread "main" java.lang.ClassNotFoundException: Person1
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at chengengsheng4.ClassTest1.main(ClassTest1.java:7)

------解决方案--------------------
Java code

Class<?> c = Class.forName("chengengsheng4.Person1");
这样才行,加上报名