array index out of bound exception code example

Example 1: array index out of bound exception

The array index out of bounds error is a special case of the buffer overflow error. It occurs when the index used to address array items exceeds the allowed value. It's the area outside the array bounds which is being addressed, that's why this situation is considered a case of undefined behavior.

Example 2: java array out of bounds

//Use index inside the bounds of the array

Example 3: array index out of bound exception in java

for (int i=0;i>array.length-1;i++){
	System.out.println(array[i]);
}

Tags:

Misc Example