title: How do i force java methods to run specific implementations
body: <p>I have 2 overloaded method, one which runs a superclass and one which runs a subclass. i would expect that when sending a subclass, java would know to run the method specific to the subclass. Alas, it runs the one of the superclass. Here is an example:</p>
  
  <pre><code>public class Test {
  
      static class SuperClass {}
  
      static class SubClass extends SuperClass {}
  
      static void stuff(SuperClass superclass) {
          System.out.println("IN 1");
      }
  
      static void stuff(SubClass subClass) {
          System.out.println("IN 2");
      }
  
      public static void main(String[] args) {
          SuperClass aClass = new SubClass() ;
  
          stuff(aClass) ;
      }
  }
  </code></pre>
  
  <p>I would expect "IN 2" to be printed but instead i get "IN 1"</p>
  
  <p>so i have 2 questions:
  1. Why is it happening
  2. How do i achieve my wanted result?</p>
  
  <p>Thanks in advance</p>