Basically, I have:
public abstract class AbstractClass {
public AbstractClass( Type arg0, Type arg1, Type arg2 ) {
}
public AbstractClass( Type onlyOneArg ) {
}
protected someMethods() { }
}
And I have several problems in subclasses:
- First, in most cases, I should uselessly rewrite the constructors. Not very annoying, just a little dirty for the eyes.
- And, more important , I am not forced to implement both constructors (although both of them are used in the program).
An example of my current subclasses:
public class MyClass extends AbstractClass {
public MyClass( Type arg0, Type arg1, Type arg2 ) {
super( arg0, arg1, arg2 );
}
public MyClass( Type onlyOneArg ) {
super( onlyOneArg );
}
}
and
- I should be able to write some specific code in the constructor of the subclass if I want.
- I have too much common code that I want to keep in an abstract class.
Can i do something? Is there something I don't know about Java? Or is my design bad? Or..?
source
share