public class CanShuDemo {
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
int[] arr = {1, 2, 3, 4, 5};
change(arr);
System.out.println(arr[1]); // 4
}
public static void change(int a1, int b1) {
System.out.println("a1:" + a1 + ",b1:" + b1); // a1:10 ,b1:20
a1 = b1; // a: 20
b1 = a1 + b1; // b: 40
System.out.println("a1:" + a1 + ",b1:" + b1); // a1:20 ,b1:40
}
public static void change(int[] arr1) {
for (int x = 0; x < arr1.length; x++) {
if (arr1[x] % 2 == 0) {
arr1[x] *= 2;
}
}
}
}
标签:a1,20,int,System,参数传递,b1,out
From: https://www.cnblogs.com/qiwei-bigdata/p/18333483