[HD-OCP17/21-Fundamentals Pg 265, Sec. 11.1.6 - manipulating-strings]

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
raphaelzintec
Posts: 167
Joined: Sun Apr 21, 2024 10:43 am
Contact:

[HD-OCP17/21-Fundamentals Pg 265, Sec. 11.1.6 - manipulating-strings]

Post by raphaelzintec »

Furthermore, any method that attempts to access an index that is beyond the range of this array throws IndexOutOfBoundsException.

so basically all String methods throw IndexOutOfBoundsException except substring() which throws StringIndexOutOfBoundsException ?

admin
Site Admin
Posts: 10383
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD-OCP17/21-Fundamentals Pg 265, Sec. 11.1.6 - manipulating-strings]

Post by admin »

For most of the methods (that throw IOOBE) of the String class, the JavaDoc say these methods throws IOOBE but the implementation of some of these methods (including substring) throw SIOOBE. Since SIOOBE extends IOOBE, the implementation is technically within the agreed contract.

The JavaDoc for indexOf method says it throws SIOOBE.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 18 guests