Created
October 18, 2017 09:00
-
-
Save javamultiplex/56ccb3046f75d5228ca193dd2644b8a1 to your computer and use it in GitHub Desktop.
Example of ArrayIndexOutOfBoundsException present in java.lang package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javamultiplex.java.lang.exceptions; | |
/** | |
* @author Rohit Agarwal | |
* @version 1.0 | |
* @category java.lang/Exception | |
* @since JDK 1.0 | |
*/ | |
public class ArrayIndexOutOfBoundsExceptionDemo { | |
public static void main(String[] args) { | |
int arr[] = new int[5]; | |
/* | |
* ArrayIndexOutOfBoundException will be thrown because array size is 5 | |
* whose min index is 0 and max index is 4. We are trying to access | |
* element at index 5 that not exists. | |
*/ | |
System.out.println(arr[5]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment