Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in String delete function.

 
Rajesh Shinde
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


Should this not give "StringIndexOutOfBoundsException", as the start index is 9 and s contains only 0-8 index values?
 
appu sharma
Ranch Hand
Posts: 104
Java Netbeans IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rajesh Shinde
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic