package third;
public class TransByValue {
public static void main(String[] args) {
int a = 0;
modify(a);System.out.println(a); // result = 0
int[] b = new int [1];
modify(b);
System.out.println(b[0]); //result = 1
//System.out.println(b[1]); wrong
}
public static void modify(int a) {
a++;
}
public static void modify(int[] b) {
b[0]++;
b = new int [5];
b[0]++;
b[0]++;
b[1] = 2;
}
}
JAVA引用类型与基本类型
猜你喜欢
转载自blog.csdn.net/qq_40801709/article/details/104313059
今日推荐
周排行