数组输出为什么错了?
public class Wu {public static void main(String [] args)
{
int x=0,y=0;
int array[]=new int [100];
for(int i=1;i<=100;i++)
{array[i]=y+i;
}
for(int n:array)
{ x=x+n;
}
System.out.println(x);
}
}
public class Wu { public static void main(String[] args) { int x = 0, y = 0; int array[] = new int[100]; for (int i = 1; i < array.length; i++) { // for (int i = 1; i <= 100; i++) { array[i] = y + i; } for (int n : array) { x = x + n; } System.out.println(x); } }