2(1)
<
> A constructor expression is either a self constructor invocation this(args1args1)……(argsnargsn) or a block which begins with a self constructor invocation. The self constructor invocation must construct a generic instance of the class.
class foo(val x: Int, val y: Int) {
def this(x: Int) = {
this(x, x + 1)
}
}
`this()`Java
class foo {
private final int x;
private final int y;
public foo(int x, int y) {
this.x = x;
this.y = y;
}
public foo(int x) {
final int y = x + 1;
this(x, y); //
}
}
ScalaJava`this()`
()
1
ScalaJava
> thisyhoo classythishoo
`this()``this()`
*
* abstract
* override
*
(…)
etc. ...
`this()`
()
()
IDE
()
`this()`
()