I have seen this kind of for-loop around但我不太明白。有人可以解释它是如何工作的吗?
链接示例:
public static void printPersonsWithinAgeRange(
List<Person> roster, int low, int high) {
for (Person p : roster) {
if (low <= p.getAge() && p.getAge() < high) {
p.printPerson();
}
}
}
编辑:问题已在此处回答:How does the Java 'for each' loop work?。
编辑2: Oracle教程:https://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html