JAVA基础题,为什么是34而不是四三

class E{

 

public static void change(int i, int j) {    

 

      int temp = i;    

 

      i =j;    

 

      j =temp;   

 

}   

 

public static void main(String[] args) {    

 

      int a = 3;    

 

      int b = 4;    

 

      change(a,b);    

 

      System.out.println(a);      //填在第1空

 

      System.out.println(b);      //填在第2空

 

}    

 

}

基本数据类型当参数的时候,其实是拷贝了一份本身的值给方法调用, 基本数据类型的值是不发生变化的,

你的例子中a和b 都是基本数据类型

change函数是值传递,而不是引用传递。