class Test3_Array {
public static void main(String[] args) {
int a = 10;
int b = 20;
System.out.println("a:"+a+",b:"+b); //a = 10,b = 20 1?
change(a,b);
System.out.println("a = "+a+",b = "+b); //a = 10,b = 20 4?
/* int[] arr = {1,2,3,4,5};
change(arr);
System.out.println(arr[1]);*/
}
public static void change(int a,int b) {
System.out.println("a:"+a+",b:"+b); //a = 10,b = 20 2?
a = b;
b = a + b;
System.out.println("a:"+a+",b:"+b); //a = 20, b = 40 3?
}
public static void change(int[] arr) { //1,4,3,8,5
for(int x=0; x<arr.length; x++) {
if(arr[x]%2==0) {
arr[x]*=2;
}
}
}
}
为什么在change(a,b);后面 4?那里输出的是a = 10,b = 20,
还有为什么change(a,b);后面的输出语句(4?那个位置)是最后输出的 ,还不是按输出语句的顺序1,2,3,4 在第二输出??求大神解答!
|
|