Is it possible to declare default argument in Java in String?

This question already has an answer here:

  • Does Java support default parameter values? 19 answers

  • 不,你通常会这样做的方式是重载方法,如下所示:

    public void test()
    {
        test("exampleText");
    }
    
    public void test(String name)
    {
    
    }
    

    No, it is not. However, the following is possible:

    public void test() {
        test("exampleText");
    }
    public void test(String name) {
        //logic here
    }
    
    链接地址: http://www.djcxy.com/p/20864.html

    上一篇: Java支持默认参数值吗?

    下一篇: 是否有可能在String中声明Java中的默认参数?