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());
}
}
}
I am learning the above code which tells me what is introspector and what is stopClass.
But I don’t understand what is meaning of this? for (PropertyDescriptor prop : props) ?
Usually a for() should be like this: for(i=0;i<100;i++)
Could anyone please help to further explain it? Thanks!
That’s the for each loop syntax, introduced in Java 5.