黑马程序员技术交流社区
标题:
反射ClassNotFound
[打印本页]
作者:
hollywood2014
时间:
2014-10-22 19:18
标题:
反射ClassNotFound
public class Reflection_test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
//String line=input.nextLine();
try {
Class c=Class.forName("test");
test t2=(test)c.newInstance();
t2.show();
} catch (Exception e) {
// TODO: handle exception
}
}
}
class test{
public test(){}
public void show()
{
System.out.println("hi, i am A");
}
}这段代码为什么会出现ClassNotFound错误,还请大神支招!
复制代码
作者:
dreamseekerkun
时间:
2014-10-23 01:25
包名写全要
作者:
zhappy
时间:
2014-10-23 08:32
在前面加上包名
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2