• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need Some Help with a Program  RSS feed

 
also aaron turner
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, new to the forum and I'm desperate for some help. Can't seem to get this thing to compile and run.

Here is my state class:



and my main:



I keep getting this error!

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 14
at java.lang.String.substring(String.java:1934)
at project4aaronturner.State.<init>(State.java:13)
at project4aaronturner.Main.main(Main.java:29)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

Any Ideas?? Could it have something to do with the parsing?


 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When using subString method- Always check for the length of the string before specifying the last index. There might be cases where you specify an index which is larger than the length of the String and this is what is happening in your code.
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check your private messages for an administrative matter.

Also please don't post that much code. Not a lot of our users will go through it. Try to isolate the problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!