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."); + } } }