通过

欢马劈雪     最近更新时间:2020-01-02 10:19:05

613
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
值传递不会更改调用函数的局部变量

public class Main{

  static void F(double x) {

    x = 3; // Here is the catch. Take care of pass-by-value./** 来自 时   代    Java - nowjava.com**/

    System.out.println("Before exiting F, value of x:" + x);

  }


  public static void main(String[] args) {

    double x = 5;

    F(x);

    System.out.println("value of x:" + x);

  }

}