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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -