... Method setCharAt
(lines 20 and 21) takes an integer and a character argument and sets the character at the specified position in the StringBuilder
to the character argument. Method reverse
(line 24) reverses the contents of the StringBuilder
. Attempting to access a character that’s outside the bounds of a StringBuilder
results in a StringIndexOutOfBoundsException
.
Get Java How To Program, Late Objects, 11th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.