Does Java support default parameter values?

Posted by gnavi on Stack Overflow See other posts from Stack Overflow or by gnavi
Published on 2009-06-15T18:04:28Z Indexed on 2010/05/27 3:01 UTC
Read the original article Hit count: 277

I came across some Java code that had the following structure:

public MyParameterizedFunction(String param1, int param2)
{
    this(param1, param2, false);
}

public MyParameterizedFunction(String param1, int param2, boolean param3)
{
    //use all three parameters here
}

I know that in C++ I can assign a parameter a default value. For example:

void MyParameterizedFunction(String param1, int param2, bool param3=false);

Does Java support this kind of syntax? Are there any reasons why this two step syntax is preferable?

© Stack Overflow or respective owner

Related posts about java

Related posts about parameters