ArrayIndexOutOfBoundsException for array
the statement:
public static void main(String[] args) {
int a[] = new int[ 3 ];
for( int j = 0; j <= 3; j++ )
System.out.println( a[j] );
}
gives me this:
0 0 0 Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:
3 at Untitled.main(Untitled.java:7)
Why is that so?
No comments:
Post a Comment