| | |
Reasigning variables
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2009
Posts: 10
Reputation:
Solved Threads: 0
I'm getting StringIndexOutOfBoundsException when I try to reasign the value of a variable.
I understand that this is something I would rather not do... but as I don't know the index of newRPos I can't think of another way to iterate.
Thanks
protString = protString.substring(newRPos+1, input.length()); I understand that this is something I would rather not do... but as I don't know the index of newRPos I can't think of another way to iterate.
Thanks
Last edited by peter_budo; Nov 5th, 2009 at 12:14 pm. Reason: Correcting code tags
0
#2 Nov 5th, 2009
Then also check with
if (newRPos < protString.length). Also, is there any guarantee that input.length() is going to be larger than newRPos, as both of those are indexes (i.e. a start index and an end index) not a start and length, and I don't know how substring reacts if the end index is smaller than the start index.. Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Apr 2008
Posts: 1,030
Reputation:
Solved Threads: 153
1
#3 Nov 5th, 2009
•
•
•
•
... I don't know how substring reacts if the end index is smaller than the start index..
•
•
•
•
Throws: IndexOutOfBoundsException - if the beginIndex is negative, or endIndex is larger than the length of this String object, or beginIndex is larger than endIndex.
0
#4 Nov 5th, 2009
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
- multiple variables in a mod_rewrite URL string (Linux Servers and Apache)
- Problem with variables in Windows shell script (Windows NT / 2000 / XP)
- how to get pass url variables from one page to another page with out knowing them? (ColdFusion)
- how to declare two integer variables x and y (C)
- Retreiving variables from a sql query into a form (PHP)
- Problem Unsetting Variables? (PHP)
Other Threads in the Java Forum
- Previous Thread: Question about tables
- Next Thread: Java hang man, help please.
Views: 166 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Java
3d @param affinetransform android api apple applet application arc arguments array arrays automation binary bluetooth byte c# chat class classes click client code color compare component corrupted database detection draw eclipse error event exception file fractal game givemetehcodez graphics gui guitesting helpwithhomework html ide image input integer j2me java java.xls javaprojects jmf jni jpanel julia keytool keyword linux list loop map method methods mobile netbeans newbie number object oracle pong print problem producer program programming project projectideas read recursion reflection rim scanner screen server set size sms socket sort sql string swing terminal test threads time transfer tree web windows






