title: how to use a subclass specific method in a different class?
body: <p>I have 2 classes ( PhoneCall ,SMS ) that extend another ( Communication ). In a different class (Registry) I have an ArrayList that hosts all incoming communications both phone calls and sms. My assignment asks me to create a method that returns the phone call with the longest duration (attribute of class PhoneCall). So when I run through the ArrayList with the communications I get an error that says cannot resolve method getCallDuration() that exists in the PhoneCall class.</p>
  
  <pre><code>public PhoneCall getLongestPhoneCallBetween(String number1, String number2){
      double longestConvo=0;
      for(Communication i : communicationsRecord){
          if(i.getCommunicationInitiator()==number1 &amp;&amp; i.getCommunicationReceiver()==number2){
              if(i.getCallDuration()&gt;longestConvo){
              }
  
  
          }
      }
      return null;
  }
  </code></pre>
  
  <p>So the program does not find the method in the Communication Class, but it is in one of its sub-Classes. 
  I do not really know how to proceed. If anyone could help me out , it would be really nice.</p>