这个java小程序用增强型的for循环输出,该怎么写呢?

2024-11-26 22:39:53
推荐回答(2个)
回答1:

public class Test{
public static void main(String[] args) {
int a[]={0,1,2,3,4,5,6,7,8,9};
for(int aa :a){
System.out.print(aa+" ");
}
}
}

回答2:

for (int i: a)
{
System.out.println(a[i]+" ");
}