Java initializer block syntax
Bergel, Alexandre
bergel at iam.unibe.ch
Tue Oct 9 15:43:37 UTC 2007
>> Does anyone have any idea or is it just useless?
>
> one possible use for this is to have common initialisation code that
> is evaluated before *any* constructor.
Exactly! Since a super constructor will _always_ be executed before
your constructor.
class A{
A() { /* CODE A*/ }
}
class B extends A {
B() { /* CODE B */ }
}
CODE B will always be executed before CODE A. The construction you
described is a way to short it out.
Cheers,
Alexandre
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
More information about the Squeak-dev
mailing list
|