title: Getting the name of a sub-class from within a super-class
body: <p>Let's say I have a base class named <code>Entity</code>.  In that class, I have a static method to retrieve the class name:</p>
  
  <pre><code>class Entity {
      public static String getClass() {
          return Entity.class.getClass();
      }
  }
  </code></pre>
  
  <p>Now I have another class extend that.</p>
  
  <pre><code>class User extends Entity {
  }
  </code></pre>
  
  <p>I want to get the class name of User:</p>
  
  <pre><code>System.out.println(User.getClass());
  </code></pre>
  
  <p>My goal is to see "com.packagename.User" output to the console, but instead I'm going to end up with "com.packagename.Entity" since the Entity class is being referenced directly from the static method.</p>
  
  <p>If this wasn't a static method, this could easily be solved by using the <code>this</code> keyword within the <code>Entity</code> class (i.e.: <code>return this.class.getClass()</code>).  However, I need this method to remain static.  Any suggestions on how to approach this?</p>