title: Does Java support anything like the c# new modifier for functions?
body: <p>In languages such as C#, there's a curious feature called method hiding. It is achieved by applying the 'new' modifier to functions and methods which have the same name as functions or methods in the base class.  It differs from overriding in that it's not replacing the implementation, it's replacing the entire thing, signature and all. It essentially says 'When using this subclass, I don't care if a method 'foo' exists in the base class, I'm defining 'foo' to be exactly what I want, right here.'  You can change the arguments, the return type, or even change it to return void instead.  Again, it's as if the base class version doesn't exist.</p>
  
  <p>This is of course horrible in that it completely breaks polymorphism. However, I've found one use where this can actually be a benefit, while implicitly still supporting polymorphism too.</p>
  
  <p>Consider the following.  (Note: I'm writing it in pseudo-Java, but with the <code>new</code> keyword as it appears in C#. I'm also omitting all the unrelated boilerplate, etc.)</p>
  
  <pre><code>class Employee{}
  
  class Manager extends Employee{}
  
  class JobPosition{
  
      public JobPosition(Employee person){
          _person = person;
      }
  
      private final Employee _person;
      Employee getPerson(){ return _person; }
  }
  
  class ManagementPosition extends JobPosition{
  
      public ManagementPosition(Manager person){
          super(person);
      }
  }
  </code></pre>
  
  <p>In the above, ManagementPosition can only be initialized with a Manager.  Because it's a subclass of JobPosition, it implicitly contains a getPerson function from the base class.</p>
  
  <p>The problem is even though you know 'person' is a manager, the return type is still <code>Employee</code>, meaning you have to manually perform that cast everywhere you need it. While you could expose a <code>getManager</code> method, that just adds a redundant method with the sole purpose of casting.</p>
  
  <p>Now consider this change to ManagementPosition instead, using the 'new' modifier to hide the original version of getPerson...</p>
  
  <pre><code>class ManagementPosition extends JobPosition{
  
      public ManagementPosition(Manager person){
          super(person);
      }
  
      new Manager getPerson(){
          return (Manager)super.getPerson();
      }
  }
  </code></pre>
  
  <p>In this case, now getPerson returns an actual manager.  And because the signature is otherwise completely identical, it doesn't break polymorphism either. You can still pass this anywhere that takes a JobPosition and getPerson will still return an employee.  Even functions that take an Employee can take the manager returned from getEmployee.  But when you need manager-specific members, it's already casted for you.</p>
  
  <p>So what I'm wondering is, does Java have anything similar to this capability?</p>