Loosen Constructor super()/this() call restrictions (original) (raw)
Marek Kozieł develop4lasu at gmail.com
Mon Mar 23 02:56:49 PDT 2009
- Previous message: Loosen Constructor super()/this() call restrictions
- Next message: Loosen Constructor super()/this() call restrictions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2009/3/23 Howard Lovatt <howard.lovatt at iee.org>:
A few notes:
3. You shouldn't be able to access super fields or any instance methods before super. -- Howard.
Can you ensure that ?
class A { private Bar bar;
public A(Bar bar) {
setBar(bar);
}
protected void setBar(Bar bar) {
this.bar = bar;
}
}
class B extends A { private Bar bar; private Foo foo;
public B(Bar bar, Foo foo) {
super(bar);
this.foo = foo;
}
protected void setBar(Bar bar) {
this.bar = bar;
this.foo = bar.foo;
}
}
Will code have same effect when constructor will be : public B(Bar bar, Foo foo) { this.foo = foo; super(bar); }
-- Pozdrowionka. / Regards. Lasu aka Marek Kozieł
http://lasu2string.blogspot.com/
- Previous message: Loosen Constructor super()/this() call restrictions
- Next message: Loosen Constructor super()/this() call restrictions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]