array index out of bound exception in java

https://w‮ww‬.lautturi.com
array index out of bound exception in java
/**
 * @author lautturi.com
 * Java example: java index out of bound exception example
 */

import java.util.*;
import java.time.*;
import java.time.format.*;

public class Lautturi {

	public static void main(String[] args) {

		int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
	      
		System.out.println(arr[11]);
	}

}

output:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 11

ArrayIndexOutOfBoundsException occurs when the index used to address array items exceeds the allowed value.
The last index is 10.

catch array out of bounds exception java

try {
    System.out.println(arr[index]);
}
catch(ArrayIndexOutOfBoundsException exception) {
    handleTheExceptionSomehow(exception);
}
Created Time:2017-09-01 05:40:41  Author:lautturi