PDA

View Full Version : IndexOutOfBounds Sometime....



JPHamlett
02-02-2013, 03:07 AM
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(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main (AppMain.java:120)

MalikDz
02-08-2013, 06:16 AM
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