title: Dynamically passing different objects to same method
body: <p>I have a method that does the same task for 4 different kind of classes when passed as parameters. Currently, I have to write that method 4 times for all 4 of those classes. Example:</p>
  
  <pre><code>doSomethingForClass1(MyClass1 myclass1, Address address);
  doSomethingForClass2(MyClass2 myclass2, Address address);
  doSomethingForClass3(MyClass3 myclass3, Address address);
  doSomethingForClass4(MyClass4 myclass4, Address address);
  </code></pre>
  
  <p>All these methods are doing the same thing and returning the same object. How can I consolidate it into one method and pass different objects? </p>