All Questions

162
votes
15answers
399401 views

What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?

What does ArrayIndexOutOfBoundsException mean and how do I get rid of it? Here is a code sample that triggers the exception: String[] name = {"tom", "dick", "harry"}; for(int i = 0; i<=name.leng...
-7
votes
2answers
32745 views

How to avoid ArrayIndexOutOfBoundsException or IndexOutOfBoundsException?

If your question is I am getting a java.lang.ArrayIndexOutOfBoundsException in my code and I do not understand why it is happening. What does it mean and how can I avoid it? This is meant to be th...
9
votes
7answers
13431 views

No out of bounds error

I have this code in C which takes in bunch of chars #include<stdio.h> # define NEWLINE '\n' int main() { char c; char str[6]; int i = 0; while( ((c = getchar()) != NEWLINE)) { str[i] ...
2
votes
4answers
30996 views

Why does ArrayIndexOutOfBoundsException occur and how to avoid it in Android?

Why does ArrayIndexOutOfBoundsException occur and how to avoid it in Android?
224
votes
4answers
255744 views

Java string split with "." (dot)

Why second line of this code in Java throws ArrayIndexOutOfBoundsException? String filename = "D:/some folder/001.docx"; String extensionRemoved = filename.split(".")[0]; While below works: String...
148
votes
11answers
237012 views

Initial size for the ArrayList

You can set the initial size for an ArrayList by doing ArrayList<Integer> arr=new ArrayList<Integer>(10); However, you can't do arr.add(5, 10); because it causes an out of bounds exc...
9
votes
6answers
163263 views

IndexError: list index out of range and python

I'm telling my program to print out line 53 of an output. Is this error telling me that there aren't that many lines and therefore can not print it out?
4
votes
2answers
36204 views

java.lang.ArrayIndexOutOfBoundsException: 0

I am learning java using a book. There is this exercise that I can't get to work properly. It adds two doubles using the java class Double. When I try to run this code in Eclipse it gives me the error...
0
votes
5answers
11127 views

Understand Arraylist IndexOutOfBoundsException in Android

I get a lot of IndexOutOfBoundsException from the any Arraylist I use. Most of the times it works fine but sometimes I get this annoying error on Arraylists i use on my project. The main cause is al...
2
votes
1answers
1286 views

java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at com.sun.faces.renderkit.ServerSideStateHelper.getState

When I use this code without <p:tab> it works as expected, <h:form> <p:wizard> <p:tab title="Test-1"> <h:form> <p:growl id="m...

Previous Next