【发布时间】:2013-05-04 07:21:35
【问题描述】:
我正在复习一个练习题,我只想知道程序如何得出答案的顺序 ---> 2 1 我主要无法理解主要的驱动程序调用。我了解这些方法的用法。
代码是:
public class Test {
public static void main(String[] args) {
int[] x = {1, 2, 3, 4, 5};
increase(x);
int[] y = {1, 2, 3, 4, 5};
increase(y[0]);
System.out.println(x[0] + " " + y[0]);
}
public static void increase(int[] x) {
for (int i = 0; i < x.length; i++)
x[i]++;
}
public static void increase(int y) {
y++;
}
}
【问题讨论】:
-
查看变量范围并按值传递。
-
向我们解释您所知道的以及您认为它应该如何工作。
标签: java arrays methods for-loop