title: How do I create a method passing an object implements an interface?
body: <p>I have defined an interface like this:</p>
  
  <pre><code>public interface InterfaceA {
        String getMyString();
  }
  </code></pre>
  
  <p>And I have two classes that implement the interface:</p>
  
  <pre><code>public class MyClassA implements InterfaceA {
       @Override
       public String getMyString(){
            return "A";         
       }
  }
  
  public class MyClassB implements InterfaceA {
       @Override
       public String getMyString(){
            return "B";         
       }
  }
  </code></pre>
  
  <p>What I am trying to do is to create a method that accepts an object that implements <code>InterfaceA</code> as an argument and call its <code>getMyString method</code>. Here is some pseudo code that illustrates what I'm trying to accomplish:</p>
  
  <pre><code>public String getStringTest(T implements InterfaceA){
       return T.getMyString;         
  }
  </code></pre>