title: How to check whether two objects are of the same class?
body: <p>If I have two objects as follows...</p>
  
  <pre><code>ClassA classAInstance = ...
  ClassB classBInstance = ...
  </code></pre>
  
  <p>... where ClassB is a direct sub-class (extension) of ClassA and the actual object assigned to 'classAInstance' and 'classBInstance' can be an instance of ClassA, ClassB or a direct or indirect sub-class of ClassA...</p>
  
  <p>How do I then check whether the object assigned to each of 'classAInstance' and 'classBInstance' is of the same Class? Is the following correct...</p>
  
  <pre><code>classAInstance.getClass().equals(classBInstance.getClass());
  </code></pre>
  
  <p>... or is it some other property that I should be comparing?</p>