The String substring (int, int) method throws IndexOutOfBoundsException exception ,
But why did not the declaration of the method throws IndexOutOfBoundsException it ?
------ Solution ------------------------------------ --------
this is a runtime exception , which is able to avoid through the code with no throws
------ Solution --------- -----------------------------------
because IndexOutOfBoundsException is a subclass of RuntimeException , belonging to a runtime exception , no declaration.
------ Solution ---------------------------------------- ----
because it is java.lang.RuntimeException exception.
------ For reference only ---------------------------------- -----
original, learn . . . Results posted .
------ For reference only -------------------------------------- -
, the child is java.lang.RuntimeException exception thrown without declaring
没有评论:
发表评论