java reflect 由参数取得对应的类的方法函数
来源:互联网 发布:网络招商 编辑:程序博客网 时间:2024/05/01 17:25
/******************************
* @author
* @date Feb 22, 2012 2:22:55 PM
* @version V1.0
*******************************/
import java.lang.reflect.Method;
public class Test2 {
public String f1(String xx, String ab) throws NullPointerException {
System.out.println("================sad" + xx);
if (xx == null)
throw new NullPointerException();
return xx;
}
public static void main(String args[]) {
try {
Class cls = Test2.class;
System.out.println("================1");
Object[] args1 = new Object[] {"tt","aa" };
Class[] argClass = new Class[args1.length];
for (int i = 0; i < args1.length; i++) {
argClass[i] = args1[i].getClass();
}
System.out.println("================2"+argClass.length);
Method m = cls.getMethod("f1", argClass);
System.out.println("================sad2");
m.invoke(new Test2(), args1);
} catch (Throwable e) {
System.err.println(e);
}
}
}
* @author
* @date Feb 22, 2012 2:22:55 PM
* @version V1.0
*******************************/
import java.lang.reflect.Method;
public class Test2 {
public String f1(String xx, String ab) throws NullPointerException {
System.out.println("================sad" + xx);
if (xx == null)
throw new NullPointerException();
return xx;
}
public static void main(String args[]) {
try {
Class cls = Test2.class;
System.out.println("================1");
Object[] args1 = new Object[] {"tt","aa" };
Class[] argClass = new Class[args1.length];
for (int i = 0; i < args1.length; i++) {
argClass[i] = args1[i].getClass();
}
System.out.println("================2"+argClass.length);
Method m = cls.getMethod("f1", argClass);
System.out.println("================sad2");
m.invoke(new Test2(), args1);
} catch (Throwable e) {
System.err.println(e);
}
}
}
- java reflect 由参数取得对应的类的方法函数
- java reflect 获取对象的方法及参数
- 函数的参数对应
- Oracle函数取得姓名对应的拼音
- java 取得虚拟目录对应的绝对路径
- java 取得虚拟目录对应的绝对路径
- Java反射reflect学习笔记_3:反射类的方法
- 由数据库数据类型得到JAVA对应类型的工具类
- 取得URL及其参数的函数
- struts2 jsp取得action参数的方法
- Java的reflect
- java的reflect
- java Map的问题取得最大value对应的key
- 由dataview生成对应的datatable的方法
- Python进阶04 函数的参数对应
- Python进阶04 函数的参数对应
- Python进阶04 函数的参数对应
- Python进阶04 函数的参数对应
- hibernate annotation多对多中间表添加其他字段的第三种方法
- BM算法的个人理解
- 基于差分图像的目标跟踪(附Matlab源码)
- Hibernate中多对多的annotation的写法(中间表可以有多个字段)
- bernate中间表配置其他字段(列) annotation不知道怎么配置~
- java reflect 由参数取得对应的类的方法函数
- linux top命令详解
- 使用HashMap输出的顺序
- Camera总结
- 在windows上搭建一个SSH隧道Set up a Windows SSH tunnel in 10 minutes or less)
- Java的Socket(一)
- H.264-AVC视频编码原理及实现(一)
- android中创建有自身特色的字符串
- Qt 程序启动画面QSplashScreen的使用