title: Super class method and submethods for subclasses in runtime
body: <p>I have method with super class as argument in main class.</p>
  
  <pre><code>public class MainClass() {
  ...
      public void myMethod(MyClass class)
  ...
  </code></pre>
  
  <p>In runtime this object can be any of its subclasses and it should call different method depending on subclasses in same main class</p>
  
  <pre><code>public class MainClass() {
  ...
      public void mySubMethod(MySubClass1 class)
  
      public void mySubMethod(MuySubClass2 class)
  ...
  </code></pre>
  
  <p>Of course, I can use instanceOf or Static Factory Pattern with Enum but still it will be (pseudo code) </p>
  
  <pre><code>public void myMethod(MyClass class) {
  if (instanceOf == MySubclass1) mySubMethod((MySubClass1)subClass1Object)
  if (instanceOf == MySubclass2) mySubMethod((MySubClass2)subClass2Object)
  }
  </code></pre>
  
  <p>In runtime jvm knows which subclass exactly object is and knows for each sub-method argument should be. I don't have control over MyClass, MySubclass1 and MySubclass2,...</p>
  
  <p>But is there any elegant way to achive this?</p>