
Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
On Wed, 21 Dec 2005 10:45:51 +0100, Thomas Weidenfeller
<nobody@ericsson.invalid> wrote, quoted or indirectly quoted someone
who said :
>> class B extends A {
>> public B() {
[quoted text clipped - 16 lines]
>You probably think about calling ordinary methods from a constructor.
>That, if not properly done, can cause problems.
If you have a B(String id) constructor, Java WON'T create the default
no-arg constructor for you. If you don't write a no-arg constrictor,
and go ahead and attempt to use it anyway, Java will give you a
compile time error. Java only creates the no-arg constructor if you
have no constructors defined.
A constructor calling another with this(...) is common to provide
default parameters.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
EdUarDo - 21 Dec 2005 10:31 GMT
> A constructor calling another with this(...) is common to provide
> default parameters.
But since the attribute is already initialized to "" in the superclass, why don't use super() instead of this("")?
Roedy Green - 21 Dec 2005 12:23 GMT
On Wed, 21 Dec 2005 11:31:37 +0100, EdUarDo
<eduardo.yanezNOSPAM@NOSPAMgmail.com> wrote, quoted or indirectly
quoted someone who said :
>> A constructor calling another with this(...) is common to provide
>> default parameters.
>
>But since the attribute is already initialized to "" in the superclass, why don't use super() instead of this("")?
Because this("") is more encapsulated. It depends only on the
behaviour of the current class, not the superclass. You want to
create as few interdependencies between classes as possible and you
don't want to write code that depends on undocumented current
behaviour. That could easily change and your code would mysteriously
stop working.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.