java - Force signature for couple of methods in class -


is possible force signature couple of methods in class?

let's have interface myinterface:

public interface myinterface {     public void method(int a); } 

and want implement myinterface in class myinterfaceclass in way each method in myinterfaceclass got same signature?

public class myinterfaceclass implements myinterface {     public void method_a(int a) { /*something */ }     public void method_b(int a) { /*something */ }     public void method_c(int a, int b) { /*something */ } // error cause of signature, won't compile } 

i have unknown number of methods in myinterfaceclass.

i can't tell after here? in java, method's signature made of 6 factors:

  1. privacy level (public, private, etc...)
  2. return type
  3. method name (cap sensitive)
  4. parameters (type , position, method_a(int a, string b) != method_a(string b, int a) )
  5. checked exception list

if wish implement method in interface, must match of these criteria including name. further, in class may implement interface's method once. if try implement method same args, name, privacy level, etc... twice class not compile. how java virtual machine know method call if implemented twice in same class?

why want implement same method twice in 1 class? maybe trying improve design asking wrong question?


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -