Register Login
DioEnglish.com Return Index

kenxio's Space http://www.dioenglish.com/?5002 [Favorites] [Copy] [Shares] [RSS]

Blogs

Java reflection

545 views. 2009-6-2 09:41 |

What is java reflection ,maybe we have no chance to use it when we are coding.But it is a very useful mechanism in java.If you really know it more clearly , it is helpful to learn others more clearly.

Simply , Reflection is a mechanism for a program or a java bean to check up itself. You can use it to operate the inside property and method directly

class EX {
}
public class instance1 {
public static void main(String args[]) {
try {
Class cls = Class.forName("EX");

Method m[] = cls .getDeclaredMethods();
for (int i = 0; i < m.length; i++)
System.out.println(m[i].toString());


boolean b1 = cls.isInstance(new Integer(37));
System.out.println(b1);
boolean b2 = cls.isInstance(new EX());
System.out.println(b2);
} catch (EXCPTION e) {
System.err.println(e);
}
}
}

Comment (0 replies)

facelist doodle 涂鸦板

You need to login first Login | Register

每周一篇英文日志,坚持一年,你的英语能力将发生质的飞跃!

DioEnglish.com --- A Nice Place to Practice English and Make New Friends!

English Writing, English Blog, English Diary, 英语角, 英语写作, 英文写作, 英语交流, 英语日记, 英语周记, 英文日记, 英语学习, 英语写作网, 英语作文大全

Website Rules|Contact Us|茶文化|英文博客网 ( 京ICP备06064874号-2 )

GMT+8, 2024-5-15 04:38

Powered by DioEnglish.com

© 2008-2013 China English Blogs

Top