JavaSE 参数传递机制 值传递和引用传递
作者:互联网
package array;
public class FcuntionDemo3 {
public static void main(String[] args) {
int a = 10;
change(a);
System.out.println(a + " ---> line 7");
}
public static void change(int a) {
System.out.println(a + " ---> line 11");
a = 20;
System.out.println(a + " ---> line 13");
}
}
package array;
public class FunctionDemo4 {
public static void main(String[] args) {
int[] arrs = {10, 20, 30};
change(arrs);
System.out.println(arrs[1] + " ----> line 7");
}
public static void change(int[] arrs) {
System.out.println(arrs[1] + " ----> line 11");
arrs[1] = 222;
System.out.println(arrs[1] + " ----> line 13");
}
}
标签:参数传递,line,System,传递,arrs,println,JavaSE,public,out 来源: https://blog.csdn.net/dyw3390199/article/details/121125684