title: how to reuse method by passing different class object?
body: <p>I have 3 Model classes like Class A, Class B and Class C with same variables and same setter and getter methods . </p>
  
  <p>All three model has getname() and setName(String s) methods.</p>
  
  <p>Another I have controller class where I have created one method. As mention below:</p>
  
  <pre><code>public void method1(Object obj)
  {
   String s = obj.getname();
  }
  </code></pre>
  
  <p>Now I want to call this method by passing model class parameters like  method1(A a), method1(B b)</p>
  
  <p>I want to reuse above method by passing different class instance.</p>
  
  <p>Below i am mentioning whole scenario what I want.</p>
  
  <pre><code> public class Controller {
     public void method1(Object obj)
     {
       String s = obj.getname();
     }
  
     public void callingMethod()
     {
       if(somecondtion)
       { 
         method1(new A());
       }
       if(somecondtion)
       { 
         method1(new B());
       }
  
       if(somecondtion)
       { 
         method1(new C());
       }
  
     }
  </code></pre>
  
  <p>When I do the above code, java is gving me error which says "method could not resolve"</p>
  
  <p>How can I achieve above problem ?</p>
  
  <p>Thanks</p>