java动态机制--反射技术内容摘要:
class SampleInterface { public static void main(String[] args) { try { RandomAccessFile r = new RandomAccessFile(myfile, r)。 printInterfaceNames(r)。 } catch (IOException e) { (e)。 } } static void printInterfaceNames(Object o) { Class c = ()。 Class[] theInterfaces = ()。 for (int i = 0。 i。 i++) { String interfaceName = theInterfaces[i].getName()。 (interfaceName)。 } } } Interfaces 判定一个类是不是接口 class SampleCheckInterface { public static void main(String[] args) { Class thread =。 Class runnable =。 verifyInterface(thread)。 verifyInterface(runnable)。 } static void verifyInterface(Class c) { String name = ()。 if (()) { (name + is an interface.)。 } else { (name + is a class.)。 } } } 找出指定类所有的域成员 public static void main(String[] args) { GridBagConstraints g = new GridBagConstraints()。 printFieldNames(g)。java动态机制--反射技术
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。
用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。