Skip to content

Instantly share code, notes, and snippets.

@uncoded-ro
Created January 12, 2020 07:13
Show Gist options
  • Save uncoded-ro/cdd6e220fa424bccd1208fd1423401e8 to your computer and use it in GitHub Desktop.
Save uncoded-ro/cdd6e220fa424bccd1208fd1423401e8 to your computer and use it in GitHub Desktop.
package ro.virtualcampus.exceptii;
public class Exceptie2 {
public static void main(String[] args) throws IndexOutOfBoundsException {
int tablou[] = { 2, 4, 5, 1 };
int index = 5;
if (index >= tablou.length || index < 0)
throw new ArrayIndexOutOfBoundsException();
else
System.out.println("elementul tablou[" + index + "] este " + tablou[index]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment