![]() |
In Java programming, IndexOutOfBoundsException is a runtime exception. It may occur when trying to access an index that is out of the bounds of an array. IndexOutOfBoundsException is defined as the RuntimeException. It can be used to find the out-of-bound run-time errors of an array. It is a part of the java.lang package. In this article, we will learn how to handle a java.lang.IndexOutOfBoundsException in Java. Syntax:try {
// write code
}
catch (IndexOutOfBoundsException e)
{
// write code
}
Program to handle a java.lang.IndexOutOfBoundsException in JavaBelow is the Program to handle a java.lang.IndexOutOfBoundsException: Java
Output
IndexOutOfBoundsException: Index 3 out of bounds for length 3 Explanation of the Program:
|
Reffered: https://www.geeksforgeeks.org
Java |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |