Java doesn't support default parameters. You will need to have two constructors to do what you want.
An alternative if there are lots of possible values with defaults is to use the Builder pattern, whereby you use a helper object with setters.
e.g.
public class Foo {
private final String param1;
private final String param2;
private Foo(Builder builder) {
this.param1 = builder.param1;
this.param2 = builder.param2;
}
public static class Builder {
private String param1 = "defaultForParam1";
private String param2 = "defaultForParam2";
public Builder param1(String param1) {
this.param1 = param1;
return this;
}
public Builder param2(String param1) {
this.param2 = param2;
return this;
}
public Foo build() {
return new Foo(this);
}
}
}
which allows you to say:
Foo myFoo = new Foo.Builder().param1("myvalue").build();
which will have a default value for param2
.