I came across some Java code that had the following structure:
public MyParameterizedFunction(String param1, int param2)
{
this(param1, param2, false);
}
If you really want to, you can check it manually by using null
:
public MyParameterizedFunction(String param1, int param2, boolean param3)
{
if(param3 == null) {
param 3 = false;
}
}
However i heavily recommend using something else, like overloading or a static factory. Maybe you can get away with this, but it can lead to unexcspected behavior. For example you could have an error in your code, so that your boolean never gets a value. In this case you would not get a NullPointerException
. Instead it will look like it was set to false, which can be very confusing to debug.