提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
常量值传递的示例
public class Main { // x uses pass by constant value and y uses pass by value//来自 时代Java公众号 - N o w J a v a . c o m public static void test(final int x, int y) { System.out.println("#2: x = " + x + ", y = " + y); y = 3; // Ok to change y System.out.println("#3: x = " + x + ", y = " + y); } public static void main(String[] args) { int a = 1; int b = 3; System.out.println("#1: a = " + a +