File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in String delete function. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt in String delete function." Watch "Doubt in String delete function." New topic
Author

Doubt in String delete function.

Rajesh Shinde
Greenhorn

Joined: Jan 29, 2010
Posts: 11
Hi,


Should this not give "StringIndexOutOfBoundsException", as the start index is 9 and s contains only 0-8 index values?


scjp6 processing.....
appu sharma
Ranch Hand

Joined: Sep 20, 2009
Posts: 104

StringIndexOutOfBoundsException - if start is negative, greater than length(), or greater than end.
so your code not give exception becuse its length is 9
if you change it to

then you get StringIndexOutOfBoundsException
vinit

It doesn't matter if you win by an inch or a mile; winning's winning.
Rajesh Shinde
Greenhorn

Joined: Jan 29, 2010
Posts: 11
Yes, This gives a exception as the start index is greater then String length.

I though it might throw exception if the start index is equal to the String length, as in that case also the String index is out of bound.(as there is no value at index=9)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Doubt in String delete function.