Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

weird String index out of bounds exception. A Java error?

Status
Not open for further replies.

shift244

Programmer
Jan 5, 2004
6
MY
i've never encountered this problem before so i think it is a weird/unique instance. here i was fooling around with Strings in my code, and then i got this:

Code:
A: alakazam,
B: alakazam
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(String.java:1480)
	at StringLooper.insideCommand(DatabaseInvokerImpl.java:71)
	at StringLooper.selectedCommand(DatabaseInvokerImpl.java:51)
	at StringLooper.selectedCommand(DatabaseInvokerImpl.java:33)
	at TestDummy.main(TestDummy.java:20)
Exception in thread "main"

the code that created this is:
Code:
.
System.out.println("A: "+thevalue);
thevalue = thevalue.substring(0,thevalue.length()-1);
System.out.println("B: "+thevalue);
.
where thevalue = "alakazam" has been set earlier

i'm very sure it works for this are simple codes. i have no idea what the error is for, not how it comes about. anyone has any idea?
 
The output printed out both the values A and B correctly. In short, the lines for System.out.println did not produce that error. It must be some other lines after
>System.out.println("B: "+thevalue);

~za~
You can't bring back a dead thread!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top