|
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);
}
}
}
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