EDIT: I will leave this here as an example. Read the comments for more information, but in general: DO NOT USE THIS DESIGN! It's free!
I searched for an answer for a while, but I couldn’t find anything concrete to say, you can’t, because ... or yes, you can do it the way you do it.
So, the question is, can I create an abstract method that defines the parameters of an object type, and then something to implement it with a specific parameter type as follows:
public abstract class ToBeOverriden { public Object method1 (Object parameter); public String method2 (Object parameter); public void method3 (Object parameter); }
And then redefine it as follows:
public class Implementation { @Override public DateTime method1 (Person parameter){ return new DateTime(); } @Override public String method2 (MotorCycle parameter){ return new DateTime(); } @Override public void method3 (String parameter){ return new DateTime(); } }
Where Person is an object created by me. The return type can be any. Currently, I cannot do this. This does not allow me. I assume this is because my class does not extend Object. Although Object extends everything ... So ...
Or do I need to update my knowledge of Java? :)
EDIT: Added a more complex class structure.
Thanks!
source share