1. 程式人生 > >變量的值傳遞

變量的值傳遞

public 傳遞 ide ++ pan pri stat strong static

代碼如下:

package ClassDemo; public class Increment {
public static void main(String[] args) {
int x = 1;
System.out.println("Before the call, x is: " + x);
increment(x);
System.out.println("After the call, x is: " + x);
} private static void increment(int n) {
n++;
System.out.println("n inside the method is: " + n);
}
}

變量的值傳遞