package com.escs.xmlutils;
import java.lang.reflect.Method;
public class Test {
public String ceshi(){
System.out.println("1111111111111");
return "success";
}
public static void main(String[] args) throws Exception {
//里面写自己的类名及路径
Class<?> c = Class.forName("com.escs.xmlutils.Test");
Object obj = c.newInstance();
//第一个参数写的是方法名,第二个\第三个\...写的是方法参数列表中参数的类型
Method method=c.getMethod("ceshi2", String.class,int.class);
//invoke是执行该方法,并携带参数值
String str2= (String) method.invoke(obj, new Object[]{"myname",4});
System.out.println(str2);
}
public String ceshi(String str){
//for(int j=0;j<Integer.valueOf(i);j++){
System.out.println(str);
//}
return str;
}
public String ceshi2(String str,int i){
for(int j=0;j<i;j++){
System.out.println(str+"22222");
}
return str;
}
}
public String fanShe(String methodName,String className) throws ClassNotFoundException, SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{
//里面写自己的类名及路径
Class<?> c = Class.forName(className);
Object obj = c.newInstance();
//第一个参数写的是方法名,第二个\第三个\...写的是方法参数列表中参数的类型
Method method=c.getMethod(methodName, String.class,int.class);
//invoke是执行该方法,并携带参数值
String str2= (String) method.invoke(obj, new Object[]{"myname",4});
return str2;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有