This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in String delete function.

 
Rajesh Shinde
Greenhorn
Posts: 11
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic