本帖最后由 沈子豪 于 2013-3-15 22:28 编辑
这个函数的运行结果不太能理解 public class Test6 { public static void main(String[] args) { int a = 10; int b = 20; System.out.println("a:" + a + ",b:" + b);//a:10,b:20 change(a, b); System.out.println("a:" + a + ",b:" + b);//a:10,b:20 System.out.println("********************************") int[] arr = { 1, 2, 3, 4, 5 }; change(arr); System.out.println("arr[1]" + arr[1]);//4 } public static void change(int[] arr) { for (int x = 0; x < arr.length; x++) { if (arr[x] % 2 == 0) { arr[x] *= 2; } } } public static void change(int a, int b) { System.out.println("a:" + a + ",b:" + b);//a:10,b:20 a = b; b = a + b; System.out.println("a:" + a + ",b:" + b);//a:20,b:40 } }
|