title: Checking if a Class object is a subtype of another Class object in Java?
body: <p>Let's say I have two <code>Class</code> objects. Is there a way to check whether one class is a subtype of the other?</p>
  
  <pre><code> public class Class1 { ... }
  
   public class Class2 extends Class1 { ... }
  
   public class Main {
     Class&lt;?&gt; clazz1 = Class1.class;
     Class&lt;?&gt; clazz2 = Class2.class;
  
     // If clazz2 is a subtype of clazz1, do something.
   }
  </code></pre>