What you want is impossible. Interfaces only prescribe which instance methods should be implemented by the class.
The static method does not need an instance of the containing class to run, and therefore, if it does not need private members, it can, in principle, be placed anywhere. Starting with Java 8, it can also be placed in an interface, but it is basically an organizational function: now you can statically static methods that βbelongβ to the interface in the interface, and you do not need to create separate classes for them (for example, the Collections class) .
Try using the following source code:
interface A { static void f() { } } public B implements A { }
Now an attempt to call Bf() or new B().f() will throw a compiler error. You must call the Af() method. Class B does not inherit static methods from an interface.
source share