title: How to save type as a variable and use it in cast
body: <p>I have the following code:</p>
  
  <pre><code>public class MyClass {...}
  
  private void foo(MyClass _param)
  
  void caller {
      Object obj = new MyClass();
      foo((MyClass)obj);
  }
  </code></pre>
  
  <p>I want to mention <code>MyClass</code> only once and use it later as follows:</p>
  
  <pre><code>void caller {
      Class&lt;?&gt; clazz = MyClass.class;
      ...
      Object obj = new clazz();
      foo((clazz)obj); // compile error: "unknown class 'clazz'"
  }
  </code></pre>
  
  <p>Is it possible to achieve?</p>