public class Test6 {
public void show(){
System.out.println("转换后的字符串为");
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
try {
//使用反射手段创建该类的对象
Test6 test =(Test6) Class.forName("com.itheima.Test6").newInstance();
//调用该对象中的方法
test.show();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//clas1.newInstance();
}
}
|
|