"call to super must be first statement in constructor"
From: Paul Chapman (paul_at_igblan.free-online.co.uk)
Date: 01/30/05
- Next message: Heiner Kücker: "Re: "call to super must be first statement in constructor""
- Previous message: KK.Frank_at_gmail.com: "Re: ant can't work"
- Next in thread: Heiner Kücker: "Re: "call to super must be first statement in constructor""
- Reply: Heiner Kücker: "Re: "call to super must be first statement in constructor""
- Reply: Ryan Stewart: "Re: "call to super must be first statement in constructor""
- Reply: Roland: "Re: "call to super must be first statement in constructor""
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 30 Jan 2005 11:39:41 -0000
Here is an example code fragment:
abstract class Outer
{
protected abstract int getValue();
protected final int value;
Outer() {
value = getValue(); }
}
class Subclass extends Outer
{
protected int getValue() {
return valueProvider.getValue(); }
private final SomeClass valueProvider;
Subclass(SomeClass aValueProvider) {
valueProvider = aValueProvider;
super(); }
}
Attempting to compile something like this produces the error message in the
subject line.
Switching the two lines in the Subclass constructor obviously won't work.
Using a separate initialize() method to initialize Outer means that
Outer.value can't benefit from the security of being final.
Is there a way out of this tangle?
Cheers, Paul
- Next message: Heiner Kücker: "Re: "call to super must be first statement in constructor""
- Previous message: KK.Frank_at_gmail.com: "Re: ant can't work"
- Next in thread: Heiner Kücker: "Re: "call to super must be first statement in constructor""
- Reply: Heiner Kücker: "Re: "call to super must be first statement in constructor""
- Reply: Ryan Stewart: "Re: "call to super must be first statement in constructor""
- Reply: Roland: "Re: "call to super must be first statement in constructor""
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|