aliamiri aliamiri - 1 year ago 81
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);

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download