Answers for "java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0"

9

exception in thread "main" java.lang.indexoutofboundsexception: index 1 out of bounds for length 1

0 means you are trying to access index 0 which is invalid, which in turn means the array is empty.
 String[] names = new String[0]; // thats the problem
 String[] names = new String[somelength];//this is true usage
Posted by: Guest on July-16-2021
0

java.lang.indexoutofboundsexception: index: 0, size: 0

0 means you are trying to access index 0 which is invalid, which in turn means the array is empty.
 String[] names = new String[0]; // thats the problem
 String[] names = new String[somelength];//this is true usage
Posted by: Guest on January-01-1970

Code answers related to "java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language