
Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
>> Are you saying that i can't call a constructor
>> in a class C from INSIDE an other constructor
[quoted text clipped - 8 lines]
> As I say, the same restriction is in Java. I don't
> think the CLR requires it, admittedly.
It's been a while i've been working with Java but i
remember that the construction was as follows.
class J {
public J () {this(5);}
public J (int i) {} }
I.e., the call to a fellow constructor has been
placed INSIDE the body and one could, as far my
memory serves me, execute statements BEFORE the
call to the constructor.
The call to the base, however, wasn't so freely
placeable. It had to come first in the constructor.
--
Regards
Konrad Viltersten
--------------------------------
sleep - a substitute for coffee for the poor
ambition - lack of sense to be lazy
Arne Vajhøj - 16 Mar 2008 01:32 GMT
> It's been a while i've been working with Java but i
> remember that the construction was as follows.
[quoted text clipped - 7 lines]
> memory serves me, execute statements BEFORE the
> call to the constructor.
The first is correct. You call this inside {}.
The second is not correct. You can not call
other statements before this.
Arne
K Viltersten - 16 Mar 2008 09:16 GMT
>> It's been a while i've been working with Java but i
>> remember that the construction was as follows.
[quoted text clipped - 12 lines]
> The second is not correct. You can not call
> other statements before this.
Then i guess i was mistaken. It's been a while
since i've touched anything bean-related, so i'll
stand corrected.
In that case, thank you both for the correction.
--
Regards
Konrad Viltersten
--------------------------------
sleep - a substitute for coffee for the poor
ambition - lack of sense to be lazy
Jon Skeet [C# MVP] - 16 Mar 2008 08:37 GMT
> It's been a while i've been working with Java but i
> remember that the construction was as follows.
[quoted text clipped - 5 lines]
> I.e., the call to a fellow constructor has been
> placed INSIDE the body
Correct.
> and one could, as far my
> memory serves me, execute statements BEFORE the
> call to the constructor.
Incorrect. From the spec
(http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html)
<quote>
The first statement of a constructor body may be an explicit invocation
of another constructor of the same class or of the direct superclass (§
8.8.7.1).
ConstructorBody:
{ ExplicitConstructorInvocationopt BlockStatementsopt }
</quote>

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk