title: Getting subclass
body: <p>That's my short Example. SuperClass:</p>
  
  <pre><code>public abstract class SuperClass
  {
      public SubClass getSubClass()
      {
          return null;
      }
  }
  </code></pre>
  
  <p>SubClass extending SuperClass:</p>
  
  <pre><code>public class SubClass extends SuperClass
  {
      public SubClass getSubClass()
      {
          return this;
      }
  
      public static void doSomething(SuperClass instance)
      {
          if(instance instanceof SubClass)
          {
              //Option 1:
              SubClass example1 = instance.getSubClass();
              //Option 2:
              SubClass example2 = (SubClass)instance;
          }
      }
  }
  </code></pre>
  
  <p>My Question is, what's the best(and without any warnings) way to get SubClass?</p>
  
  <p>In option 1, i will get 2 warnings(1. in SuperClass#getSubClass that Class references Subclass, 2. in SubClass#getSubClass that it ignores method in SuperClass).</p>
  
  <p>In option 2, i will get 1 warning(Casting to concrete Class) and i believe that option is slower too.</p>
  
  <p>Is there any other way to achieve what i want? Which option is the best?</p>