Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception in thread "main" java.lang.StringIndexOutOfBoundsException:  RSS feed

 
Tarius Peddle
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I run this program I always get:

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 6
        at java.lang.String.charAt(Unknown Source)
        at j32016.main(j32016.java:31)

What's causing the exception? How do I fix it?

 
Carey Brown
Bartender
Posts: 3022
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple of print statements would help you debug this.
 
Campbell Ritchie
Marshal
Posts: 55793
164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you still trying to get the individual chars? You have already been told there is a Scanner method which will find the ints for you.
 
Julian West
Ranch Hand
Posts: 91
3
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are trying to access a character in a string that's outside the string; i.e. "Hello".charAt(-1) or "Hello".charAt(5)

X marks the spot!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!