Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>interface</code>s cannot have <code>static</code> methods. They can have <code>static final</code> constants but not methods.</p> <p>If you want to have <code>static</code> methods you need to use an <code>abstract class</code></p> <pre><code>interface Iface { void doStuff(); } abstract class Base implements Iface { static void doStaticStuff() { } } </code></pre> <p><strong>EDIT</strong></p> <p>You cannot override <code>static</code> methods. You also cannot <code>implement</code> other classes.</p> <p>You <code>extend</code> other classes.</p> <p>You cannot solve your issue unless you either make the methods in one class non <code>static</code> or make the methods in the other class <code>static</code></p> <pre><code>static class A { static void a(){} } static class B extends A { static void a(){} } </code></pre> <p>What you are trying to do does not make any sense. How would an instance method override a <code>static</code> method?</p> <p>Notice this does <strong>not</strong> override the <code>a()</code> method in <code>A</code> it simply creates another <code>a()</code> method in <code>B</code>. The call <code>A.a()</code> will call the method <code>a()</code> in <code>A</code> and the class <code>B.a()</code> will call the method <code>a()</code> in <code>B</code>.</p> <p>It doesn't really make sense to have <code>static</code> methods called the same thing in two different classes as it causes problems with static imports and gives the impression that the method in one class overrides the other. Which it doesn't.</p> <p>In any case, even <em>if</em> you were able to override <code>static</code> methods; yours also also <code>final</code> which makes that impossible. Even if you remove the <code>static</code> you will not be able to override the methods until you also remove the <code>final</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload