reflection all methods
来源:互联网 发布:linux运维要学什么 编辑:程序博客网 时间:2024/06/08 19:26
Method Reflection
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
public class MainClass {
public static void main(String[] args) {
String name = "java.util.Date";
try {
Class cl = Class.forName(name);
Class supercl = cl.getSuperclass();
System.out.println("class " + name);
System.out.println("Its methods:");
printMethods(cl);
System.out.println();
} catch (ClassNotFoundException e) {
System.out.println("Class not found.");
}
}
public static void printMethods(Class cl) {
Method[] methods = cl.getDeclaredMethods();
for (int i = 0; i < methods.length; i++) {
Method m = methods[i];
Class retType = m.getReturnType();
Class[] paramTypes = m.getParameterTypes();
String name = m.getName();
System.out.print(Modifier.toString(m.getModifiers()));
System.out.print(" " + retType.getName() + " " + name + "(");
for (int j = 0; j < paramTypes.length; j++) {
if (j > 0)
System.out.print(", ");
System.out.print(paramTypes[j].getName());
}
System.out.println(");");
}
}
}
- reflection all methods
- Java Reflection - Methods
- Invoke methods using System.Reflection
- Java Reflection 教程(5):Methods 类方法
- Java reflection: accessing private fields and methods
- Java Reflection - Private Fields and Methods
- Java Reflection - Private Fields and Methods
- Remove all the EventHandlers of the object by reflection
- All About JAVA 如何使用反射(Reflection )
- Remove all the EventHandlers of the object by reflection
- Android Activity Life Cycle - What are all these methods for?
- Reflection
- Reflection
- Reflection
- Reflection
- Reflection
- Reflection
- Reflection
- European software vendors ranking 2012 (zz)
- 跨平台移动开发实战(八)------移动客户端网络通信
- 如何客制化自己的开机图片
- java基础——循环语句和循环中断语句
- Reducer for the maximum temperature example
- reflection all methods
- 跨平台移动开发实战(九)------移动端本地存储方案
- erlang window下执行 escript脚本
- Java基础——break和continue
- 学习NIO
- 将packages/apps/下的app导入eclipse
- 【分享】KDD Cup 2011(KDD Cup 2011比赛数据)
- 「linux」命令简介
- java基础——数组