Skip to content
Advertisement

An interface with different method parameters

I want to declare an interface be use with several classes
this classes have method with different parameters

interface:

public interface Operation {

public int Add();

}

class A:

public class CLASSA implement Operation{

     public int Add(int id,String name);

}

class B:

public class CLASSB implement Operation{

     public int Add(String name);

}

how to impelement of this interface?

Advertisement

Answer

you could make an operand-object

public interface Operation {

public int Add(Operand o);

}

or

public interface Operation {

 public int Add(Operand... o);

}
3 People found this is helpful
Advertisement