- 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错误,还请大神支招!
复制代码
|