| | |
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; 34 Days Ago at 12:14 pm. Reason: Correcting code tags
0
#2 34 Days Ago
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: 980
Reputation:
Solved Threads: 145
1
#3 33 Days Ago
•
•
•
•
... 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 33 Days Ago
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.
| Thread Tools | Search this Thread |
-xlint android api applet application array arrays automation bi binary blackberry block bluetooth chat class classes client code compile compiler component database developmenthelp draw eclipse error event exception fractal freeze game gameprogramming givemetehcodez graphics gui html ide image input integer j2me j2seprojects java javac javaprojects jetbrains jni jpanel jtable julia learningresources lego linux list login loop loops mac map method methods mobile netbeans newbie notdisplaying number online oracle page print problem program programming project qt recursion scanner screen server set singleton size sms sort sql string swing system template textfields threads time title tree tutorial-sample update variablebinding windows working xor






