View Full Version : Strange Java Runtime Error
I had to do this program for a school assignment. It is a cheesy calculator. You use input like this: x=1, x+=2, x*=3, and xxx displays the result. It seems to work fine however when I was testing it I would get String out of range exceptions. For exampel, try x_123 as a variable, like x_123=4 followed by x_123+=3, you will get the exception; then try 1_abc=4 followed by 1_abc+=4, you will not have a problem.
Can anyone explain what is causing the problem.
Istari1
04-12-02, 11:51 PM
I tried compiling this and it compiles, but I got alot more errors then just that one. I got both a Number Format exception from parseInt, and an Error from the StringTokenizer.
Josh
Not sure what to say. I just downloaded the files from the links and tried it and only get String index out of range -1 exception, Using Borland JBuilder 3.0, University edition. Thats with the x_123 example.
It was also marked on a unix machine, I demonstrated it my self, and got perfect, markers did not ask for bad variables.
Hmm, if I use the exact values "x_123=4" then "x_123+=3" I will get the string index error, but if I use x_123 and any other values it will work fine. Weird.
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.