【发布时间】:2015-09-01 08:25:36
【问题描述】:
我在其中一个教程中看到了这段代码。 它没有任何错误,但我只是不明白代码。 有人可以指导我吗?
int trying[] = {3,4,5,6,7};
change (trying);
for(int y: trying) {
System.out.println(y);
}
}
public static void change (int x[]) {
for ( int counter = 0; counter < x.length ; counter++){
x[counter] += 5;
}
}
能帮我解释一下这部分吗?
for(int y: trying) {
System.out.println(y);
}
我特别不明白这行代码:
for (int y : 尝试)
【问题讨论】:
-
表示:
for each int contained in "trying" array, set this int as "y" and execute following block