SRL Archive - Java Help and Tutorials

IndexOutOfBounds Sometime....


JPHamlett

2013-02-01 22:07:31

http://pastebin.com/m3jxH67j


Why does this sometimes throw an index out of bounds exceptions….and sometimes it wont run all the way through the class….WTF?!?!?!?!?!?!?!

Sometimes it even runs all the way through the class flawlessly…..

lol any help?

error

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at Matrix.Matrix.colSum(Matrix.java:125)
at Matrix.Matrix.main(Matrix.java:271)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

MalikDz

2013-02-08 01:16:13

You trying to access an array index that doesnt exist .
Example:

int numbers[]={0,1,2,3};
System.out.println(number[5]);



the index 5 doesnt exist and youre trying to call it, this will throw an out of bound error