previous | start | next

Cast Exceptions

The cast above works, but this one will not:

        ((SavingsAccount) b[1]).getRate() 

because at runtime, b[1] is not a SavingsAccount, it is only a
BankAccount. An exception is thrown:

        ClassCastException
   


previous | start | next