for(:)在Java中是什么意思? [英] What does this for(:) mean in Java?
本文介绍了for(:)在Java中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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.但是我不明白这是什么意思?用于(PropertyDescriptor prop:props)
吗?通常,for()应该是这样的: for(i = 0; i< 100; i ++)
有人可以帮忙进一步解释吗?谢谢!
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!
推荐答案
这是针对每个循环语法,这是Java 5中引入的.
That's the for each loop syntax, introduced in Java 5.
这篇关于for(:)在Java中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文