Xiaobo Sun

Eclipse-Unix http://umlfact.berlios.de/~s_xsun/

Java Reflection

Purpose: use the Instances of the class java.lang.Class to represent classes and interfaces in a running Java application.

1. create Object:

A a = (A)Class.forName("A").newInstance(); //If A isn't a correct Class Name, it's a Runtime-Exception "ClassForName", comparing to the Compile-Exception from "new A()"

2. get Attributes/Methods information at Runtime:

Class c = Class.forName(args[0]);
Method m[] = c.getDeclaredMethods();

posted on 2007-06-12 13:14 Xiaobo Sun 阅读(213) 评论(0)  编辑  收藏 所属分类: Java


只有注册用户登录后才能发表评论。


网站导航:
 
<2007年6月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

导航

统计

常用链接

留言簿(3)

随笔分类

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜