Super constructor problem
Hi,
I am getting the following message when i try to define a class:
Implicit super constructor Activity() is undefined for default constructor. Must define an explicit
constructor
Can anyone suggest something?
Thanx,
Vinayak.
Message was edited by:
VinuRocks
[324 byte] By [
VinuRocksa] at [2007-11-27 8:24:29]

You have probably subclassed an object. If you dont call the superclass constructor, Java makes an implicit super() call. The super class probably doesn't have a noarg constructor defined. I am guessing you have defined a constructor in the super class that takes an argument. If you hadn't Java would have added an implicit constructor
Just add a no arg constructor to the super class
There's more to the message than just that. Next time please post the entire, exact message, and also the relevant code.
It sounds like you defined a c'tor in Activity that takes one or more args. This means there's no longer a no-arg Activity() c'tor, unless you explicitly add it. In the subclass, you're not calling super(some args), so it's assuming you want to call super() with no args, but that does not exist.
Either call super(the appropriate args) or add a no-arg Activity() c'tor.
Constructor rules:
1) Every class has at least one ctor.
1.1) If you do not define an explicit constructor for your class, the compiler provides a implicit constructor that takes no args and simply calls super().
1.2) If you do define one or more explicit constructors, regardless of whether they take args, then the compiler no longer provides the implicit no-arg ctor. In this case, you must explicitly define a public MyClass() {...}
if you want one.
1.3) Constructors are not inherited.
2) The first statement in the body of any ctor is either a call to a superclass ctor super(...)
or a call to another ctor of this class this(...)
2.1) If you do not explicitly put a call to super(...) or this(...) as the first statement in a ctor that you define, then the compiler implicitly inserts a call to super's no-arg ctor super()
as the first call. The implicitly called ctor is always super's no-arg ctor, regardless of whether the currently running ctor takes args.
2.2) There is always exactly one call to either super(...) or this(...) in each constructor, and it is always the first call. You can't put in more than one, and if you put one in, the compiler's implicitly provided one is removed.
jverda at 2007-7-12 20:13:34 >
