Instead of using:
void parameterizedMethod(String param1, int param2) {
this(param1, param2, false);
}
void parameterizedMethod(String param1, int param2, boolean param3) {
//use all three parameters here
}
You could utilize java's Optional functionality by having a single method:
void parameterizedMethod(String param1, int param2, @Nullable Boolean param3) {
param3 = Optional.ofNullable(param3).orElse(false);
//use all three parameters here
}
The main difference is that you have to use wrapper classes instead of primitive Java types to allow null
input.Boolean
instead of boolean
, Integer
instead of int
and so on.