java中 定义一个数组int a【】={3,8,5,0,7,2};接下来是什么意思for(int temp:a)?

2025-03-07 01:52:47
推荐回答(5个)
回答1:

这个是Java 另一种数组遍历的方法
把a数组中的值一个一个取出来交给temp

回答2:

for是循环啊,temp按顺序取值啊

回答3:

for(int temp: a)
意思是
for(int i=0; iint temp = a[i];
...
}

回答4:

这个也是for循环中的一种 一般被称为foreach循环
等同于for循环的
for(int i=0; iint temp = a[i];}

回答5:

遍历a中元素