Advertisement
flamewheel56

ArrayIndexOutOfBoundsException

Mar 6th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.36 KB | None | 0 0
  1. public class Exception {
  2.     public static void main(String args[]) {
  3.         int[] array = new int[5];
  4.         try {
  5.             for (int i=0;i<6;i++) {
  6.                 array[i] = i;
  7.             }
  8.             System.out.println(array);
  9.         } catch (ArrayIndexOutOfBoundsException e) {
  10.             System.out.println("Loop went too far! - " + e);
  11.         } finally {
  12.             System.out.println("Array value input completed.");
  13.         }
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement