oop - Overriding a method with more parameters in java? -


i have base class method called execute :

class {     public execute(int a){} } 

i have class b, extends a, execute method needs more parameters:

currently, solution using optional parameters :

class b extends {     public execute(int a, object... parameters){         long b = (long)parameters[0];         boolean c = (boolean)parameters[1];         ....     } } 

this still ugly because must cast on parameters. there other options situation?

you can add execute(int a, int b) in b, won't override execute(int a) method, overload it. both method callable on instance of b.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -