可选参数值

类 / 方法

class Greeting {
    //Java 中没有参数默认值
    static void SayGoodby(String message) {
        System.out.println(message);
    }

    static void SayGoodby() {
        SayGoodby("Goodby!");
    }
}

Greeting.SayGoodby();
//输出 "Goodby!"

Greeting.SayGoodby("see you");
//输出 "see you"