title: java: call static method from unknown class with polymorphy
body: <p>I have superclass <code>Token</code> with some subclasses like <code>Knight</code>, <code>King</code>, <code>Queen</code>, etc.</p>
  
  <p>I need a random <code>Token</code> Type so I call this method: </p>
  
  <pre><code>public Class randomTokenType(){
      Class[] classes = {
          Bishop.class, King.class, Knight.class, Pawn.class, Queen.class, Rook.class
      };
      Random random = new Random();
      return classes[random.nextInt(6)];
  }
  
  Class&lt;Token&gt; tokenType = randomTokenType();
  </code></pre>
  
  <p>Now I want to call a static method on this tokenType, for example:</p>
  
  <pre><code>tokenType.displayString()
  </code></pre>
  
  <p>The compiler can't resolve this method even tough it's implemented in <code>Token</code> and all of its subclasses.</p>
  
  <p>What is my mistake?</p>