问题描述
- 新手问题:想用加强的for循环 但是编译不过 不知道哪里错了
-
public class test
{
public static void
main(String[] args)
{
int[] s = new int[10]{1,2,3,4,5,6,7,8,9,10};
for(int i:s)
{
System.out.println(i);
}
}
}
解决方案
int[] s = new int[10]{1,2,3,4,5,6,7,8,9,10};这个写法是不合理的,要么int[] s = new int[]{1,2,3,4,5,6,7,8,9,10};要么是int[] s = new int[10];
解决方案二:
int[] s = new int[]{1,2,3,4,5,6,7,8,9,10};
解决方案三:
int[] s = {1,2,3,4,5,6,7,8,9,10};
时间: 2024-09-22 18:14:22