我入門學習Java,我寫了一個簡單的數組示例程序,什麼是溫度和什麼是在Java中使用溫度?
public class ExampleArray {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a[] = {10, 20, 30, 40, 50};
System.out.println(a[2] + " " + a[4]);
for (int temp : a) {
System.out.println(temp);
}
}
}
這是輸出:
30 50
10
20
30
40
50
它打印從陣列中的所有值。
我可以知道,在Java中temp
有什麼用?
任何人都可以解釋這個關鍵字嗎?
temp是一個局部變量名.read爲循環增強http://www.cis.upenn.edu/~matuszek/General/JavaSyntax/enhanced-for-loops.html – 2014-12-06 11:39:43
在Java中尋找for-each循環'! – 2014-12-06 11:41:16
http://docs.oracle.com/javase/1.5.0/docs/guide/language/foreach.html – 2014-12-06 11:41:21