package MyTest;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
class Person {
...
}
class Student extends Person {
...
}
public class IntrospectorDemo {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
BeanInfo info = Introspector.getBeanInfo(Student.class, Person.class);
PropertyDescriptor[] props = info.getPropertyDescriptors();
for (PropertyDescriptor prop : props) {
System.out.println(prop.getName() + "::" + prop.getPropertyType());
}
}
}
我正在学习上面的代码,它告诉我什么是内省器,什么是 stopClass。
但我不明白这是什么意思?for (PropertyDescriptor prop : props)
?
通常 for() 应该是这样的:for(i=0;i<100;i++)
有人可以帮忙进一步解释一下吗?谢谢!
这就是对于每个循环 http://docs.oracle.com/javase/6/docs/technotes/guides/language/foreach.html语法,在 Java 5 中引入。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)