title: Calling child method, when cast to parent type in java
body: <p>I am having problems with some course work i'm trying to finish off and any help would be appreciated!</p>
  
  <p>I have 3 types of accounts which extend an abstract type "Account".. [CurrentAccount, StaffAccount and MortgageAccount].</p>
  
  <p>I am trying to read in some data from file and create account objects along with user objects to add to hashmaps stored within the program.</p>
  
  <p>When I create account objects I use a temporary variable of type Account and define its subtype dependant on the data read in.</p>
  
  <p>for example:</p>
  
  <pre><code>Account temp=null;
  
  if(data[i].equalsIgnoreCase("mortgage"){
      temp= new MortgageAccount;
  }
  </code></pre>
  
  <p>Problem is when I try to call a method belonging to type MortgageAccount..</p>
  
  <p>Do I need a temp variable of each type, StaffAccount MortgageAccount and CurrentAccount and use them coresspondingly in order to use their methods?</p>
  
  <p>Thanks in advance!</p>