From b737f00e0dcae9799e2652869228e8e195121007 Mon Sep 17 00:00:00 2001 From: Aayush1472012 <62372257+Aayush1472012@users.noreply.github.com> Date: Thu, 1 Oct 2020 18:00:59 +0530 Subject: [PATCH] Update IndexOutOfBound.java --- inheritance/IndexOutOfBound.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/inheritance/IndexOutOfBound.java b/inheritance/IndexOutOfBound.java index 0e68436..6b500cc 100644 --- a/inheritance/IndexOutOfBound.java +++ b/inheritance/IndexOutOfBound.java @@ -2,9 +2,13 @@ public class IndexOutOfBound { public static void main( String[] args ) { - int[] test = new int[5]; - - test[6] = 666; + try{ + int[] test = new int[5]; + test[6] = 666; + }catch (IndexOutOfBoundsException e){ + System.out.println("IndexOutOfBoundsException: You try to access" + + " element of array of index greater than length of array."); + } } }