提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
值传递不会更改调用函数的局部变量
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); } }