Skip to content

Instantly share code, notes, and snippets.

@mounicasrinivas
Created December 19, 2023 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mounicasrinivas/c0fe0361c0e60689668e3b44bd2511f4 to your computer and use it in GitHub Desktop.
Save mounicasrinivas/c0fe0361c0e60689668e3b44bd2511f4 to your computer and use it in GitHub Desktop.
ArrayIndexOutOfBoundsException
int[] myArray = {10, 20, 30, 40, 50};
// Accessing a valid index
int validElement = myArray[2];
// Attempting to access an invalid index (outside bounds)
// This would throw an ArrayIndexOutOfBoundsException
int invalidElement = myArray[5];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment