Howdy ranchers,
the API says about StringBuffer's delete(int start,int end) method:
Throws:
StringIndexOutOfBoundsException - if start is negative, greater than length(), or greater than end.
This makes sense, because there is always a null
string at the end of a character sequence, so the 3 is ok, 4 is too high.
More about this (yet a different question) on
http://faq.javaranch.com/java/ScjpFaq#kb-regexp (have a look on the image there)
Note, that delete() does not throw an exception, if the "end" number is too high.
Yours,
Bu.