package HspLearningoop;
public class Demon05 {
public static void main(String[] args) {
int a = 10;
int b = 20;
BB bb = new BB();
bb.swp(a,b);
System.out.println("该方法中ab的值"+a+" "+b);
}
}
class BB{
public void swp(int a , int b){
System.out.println("交换前的值为:" + "a=" + a + "b=" + b);
int temp = a;
a = b;
b = temp;
System.out.println("交换后的值为:"+"a=" + a + " " + "b=" + b);
}
}
//结论:
//基本数据类型,传递的是值(值拷贝),形参的任何变化不会影响实参!
网友评论