title: Why does java allow for overriding methods with subclass return types but not subclass parameters?
body: <p>If I have an abstract (or any as far as I know) superclass in java like so:</p>
  <pre><code>public abstract class Person {
      public abstract Person getPerson(Person p);
  }
  </code></pre>
  <p>I noticed that a subclass can use itself for the return type, but not the parameter when overriding this method:</p>
  <pre><code>public class Child extends Person {
      @Override
      public Child getPerson(Person p) { //Works fine
          return this;
      }
  
      @Override
      public Person getPerson(Child p) { //Doesn't work
          return this;
      }
  }
  </code></pre>
  <p>Why is this not allowed? I'm not asking for a solution - I know I could just use an <code>instanceof</code> check in the method or something, I'm more asking why the former is acceptable and the latter is not to the compiler.</p>