title: How to compare two classes
body: <p>I'm trying to create a factory, here's the code:</p>
  
  <pre><code>public class MyFactory {
      public static &lt;T&gt; MyBase create(Class&lt;T&gt; _c) {
          if (_c.getClass().equals(Derived1.class)) // (1)
              return createNewDerived1();
  
          return null;
      }
  }
  
  // caller
  MyFactory.create(Derived1.class);
  </code></pre>
  
  <p>It compiles with warning at line <code>(1)</code>:</p>
  
  <h2>Error</h2>
  
  <pre><code>'equals()' between objects of inconvertible types 'Class&lt;Derived1&gt;'
   and 'Class&lt;capture of ? extends Class&gt;' Reports calls to .equals()
   where the target and argument are of incompatible types. While such a
   call might theoretically be useful, most likely it represents a bug.
  </code></pre>
  
  <p>And in runtime my <code>if</code> statement fails for some reason.
  How can I get the intended behaviour?</p>