|
-
July 15th, 2009, 02:41 PM
#1
Index OOB Exception Error
I'm sure you've all become quite familiar with this "four letter word" in your travels, as have I.
The exact error is as follows:
-----
Exception in thread "main" java.lang.IndexOutOfBoundsException. Index:4 Size: 4.
at java.util.ArrayList.RangeCheck(ArrayList.java:546)
-----
What I don't really get, is before getting this message, I wasn't dealing with arrays(or ArrayLists), but a StringBuilder value I had just inserted. At that point, i get this error.
Is there anyway, to detect if it really IS a fluke arraylist exception error, elsewhere in my code. And if so, is there a simple way of finding this fluke code?
=Thanks
-
July 16th, 2009, 04:00 AM
#2
Re: Index OOB Exception Error
I don't know what you mean by a 'fluke' error, but errors in programs are usually the result of mistakes or omissions. StringBuilder uses arrays internally, but it's pretty unlikely to be a bug in StringBuilder - it's more likely that it is being used incorrectly - if you look at the API docs, there are methods that will throw this exception if you pass incorrect arguments.
If you have the full stack trace (you seem to have posted just the first two lines), the first line you come to that refers to a class or method in your own code will tell you where to look first. Without seeing the relevant code and the full stack trace, it's not possible to be more specific.
It is easier to measure something than to understand what you have measured...
Anon.
Last edited by dlorde; July 16th, 2009 at 04:24 AM.
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|