title: Compare 2 subclass instances with same super class
body: <p>I have 2 sub-class (Student, Teacher) and a superclass (Occupation).<br/>
  I have created Object A from Student and Object B from Teacher.<br/></p>
  
  <pre><code>Student A = new Student();
  Teacher B = new Teacher();
  </code></pre>
  
  <p>And I already created a static method that takes objects as arguments and returns boolean;<br/></p>
  
  <pre><code>compare(A, B);
  
  public static boolean compare(Student s, Teacher t)
  </code></pre>
  
  <p>In the method, I just put this code to compare if both object belong to the same class or not;<br/></p>
  
  <pre><code>if (s.getClass() == t.getClass())
  </code></pre>
  
  <p>And now I get the error saying:</p>
  
  <pre><code>incomparable types: Class&lt;CAP#1&gt; and Class&lt;CAP#2&gt;
  </code></pre>
  
  <p>where CAP#1,CAP#2 are fresh type-variables:</p>
  
  <pre><code>CAP#1 extends Student from capture of ? extends Student
  CAP#2 extends Teacher from capture of ? extends Teacher
  </code></pre>
  
  <p>What is wrong here ?</p>
  
  <p>NOTE: If I use the comparison s.equals(t), it doesn't have any error at all. Why can't I use the object.getClass() method correctly ?</p>