📄 3.10swap.java
字号:
public class Swap{
public static void main(String args[]){
Integer a,b;
a=new Integer(10); //Integer相当于int
b=new Integer(50);
System.out.println("before swap...");
System.out.println("a is "+a);
System.out.println("b is "+b);
swap(a,b); //交换a与b的值
System.out.println("after swap...");
System.out.println("a is "+a);
System.out.println("b is "+b);
}
public static void swap(Integer pa,Integer pb){
Integer temp=pa; //借助临时变量进行交换
pa=pb;
pb=temp;
System.out.println("in swap...");
System.out.println("a is "+pa);
System.out.println("b is "+pb);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -