aliamiri aliamiri - 6 months ago 46
Java Question

' this' in constructor

what is 'this' here? I have only this two constructor

public DefaultSpeculator(Configuration conf, AppContext context) {
this(conf, context, context.getClock());

public DefaultSpeculator(Configuration conf, AppContext context, Clock clock) {
this(conf, context, getEstimator(conf, context), clock);


Say you had a constructor:

public Something(String foo) { ... }

And you had another overloaded constructor:

public Something() { ... }

You can invoke the other constructor like this:

public Something() {

This will execute the former constructor with String parameter "foo" passed.

In your case, your first constructor invokes the second constructor with some arguments. The second constructor invokes a constructor of four arguments.