[关闭]
@w1024020103 2017-01-23T00:44:19.000000Z 字数 668 阅读 762

java.lang.ArrayIndexOutOfBoundsException: 3

algorithm java coursera


when doing week4 assignment, Eclipse reports:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:3
at Board.twin(Board.java:97)
at Board.main(Board.java:194)

What I found in oracle's javadoc:

public class ArrayIndexOutOfBoundsException
extends IndexOutOfBoundsException
Thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal to the size of the array.
Since:
JDK1.0

So, the problem is about the index of an array, check out your code like i=0;i<n;i++ , probably your index could be 4 while your array only have 4 elements, whose biggest index is 3. This exception indicates problems like this, be careful and patient.

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注