extending with unspecified constructor

I want to extend some class that has multiple constructors with different arguments. however i don't intend to do anything with the arguments in my code.

Is there a way to extend a constructer in such a way

public class(<any arguments>)

{

super(<any arguments>);

mycode();

}

void mycode()

......

without spezifieing what <any arguments> is.

[433 byte] By [arcosh] at [2007-9-26 1:39:57]
# 1
No... You have to create each constructor individually, but it really isn't that hard... Just a couple of lines of cutting and pasting...GN
statusquo at 2007-6-29 2:29:46 > top of Java-index,Archived Forums,Java Programming...
# 2
For all practical purposes statusquo is right. From a theorietical point of you, you could write a constructor that takes an array of objects (as Java does not have variable parameters), then use reflection to invoke the appropriate constructor.
CChrisB at 2007-6-29 2:29:46 > top of Java-index,Archived Forums,Java Programming...
# 3

> For all practical purposes statusquo is right.

>

> From a theorietical point of you, you could write a

> constructor that takes an array of objects (as Java

> does not have variable parameters), then use

> reflection to invoke the appropriate constructor.

this won't work because super is supposed to be the first call in a constructor, if there is one, and one is required.

parthasarkar at 2007-6-29 2:29:46 > top of Java-index,Archived Forums,Java Programming...
# 4
thats unfortunate.The copy paste part for the first time is a nuisience but not that bad.It just gets very boring if i add an additional constuctor to the extended classand then have to go through all the extending classes.
arcosh at 2007-6-29 2:29:46 > top of Java-index,Archived Forums,Java Programming...
# 5
Well, yes, but why do you have to? If the subclass doesn't have clients that need that constructor, then you don't have to add it.
chrishmorris at 2007-6-29 2:29:46 > top of Java-index,Archived Forums,Java Programming...
# 6

>It just gets very boring if i add an additional constuctor to the

>extended classand then have to go through all the extending classes

How many constructors do you have? Probably more than 5 suggests something is wrong with the design of the class.

If you are doing is simply to provide default arguments then I would suggest defining a primitive class that contains nothing but public attributes and a single default ctor. The ctor defines the standard definitions. A caller redefines the attributes they want to. Your main classes have a single ctor which takes the primitive as the only argument.

jschell at 2007-6-29 2:29:46 > top of Java-index,Archived Forums,Java Programming...