Open DevinLei opened 5 years ago
https://devinlei.github.io/java/2018/12/22/java-integer.html
public static void main(String[] args) { Integer a = 1,b=2; System.out.println("交换前a="+a+ ",b="+b); // 交换a,b值 exchange(a,b); System.out.println("交换后a="+a+ ",b="+b); } public static void exchange(Integer o1,Integer o2){ Integer temp = o1; o1=o2; o2=temp; } 运行结果: 交换前a=1,b=2 交换后a=1,b=2
https://devinlei.github.io/java/2018/12/22/java-integer.html
我们先来看一个例子