1. 程式人生 > >Java——值傳遞

Java——值傳遞

//
public class test1
{
int num = 1;
public static void main(String[] args)
{ 
int x = 12;
System.out.println("chage_pre X=" + x);
change(x);
System.out.println("chage_after X=" + x);
}
static void change(int x){
System.out.println("in_chage_pre X=" + x);
x = 20;
System.out.println("in_chage_after X=" + x);
}

}