class ArrayPrint {
static void arrayPrinter(int[] x) {
for (int i = 0; i < x.length; i++) {
System.out.println(x[i]);
}
}
public static void main(String... S) {
int[] x = {3, 3, 4, 2, 7};
x = new int[5];
arrayPrinter(x);
System.out.println(x.length);
}
}
预期的数组没有打印,而是打印0 0 0 0 0
。可能是什么错误?