ArrayIndexOutOfBoundsException in Java — What It Means and How to Fix It

What Java's ArrayIndexOutOfBoundsException means and how to fix it.

Published November 2, 2026

ArrayIndexOutOfBoundsException is thrown when an array is accessed with an index outside its valid range.

Key points

  • Read the full stack trace from the top — it names the exact class, method, and line where the exception originated

Example

int[] a = new int[3];\na[5] = 1;  // ArrayIndexOutOfBoundsException
More Java articles