Originally Posted by
ravian
StringIndexOutOfBoundsException is subclass of IndexOutOfBoundsException. So I believe that my catch will catch both Exceptions. Is this right?
I think it actually has to be IndexOutOfBoundsException that needs to be caught. Because, if you were to put Exception e instead, it catches any type of Exception. So, its the same case here, the superclass is the one that needs to be caught. Correct me if I'm wrong.