IllegalArgumentExceptionIllegalArgumentException
A method receives an argument that is not valid for its expected range or format.
ArrayIndexOutOfBoundsExceptionAn array is accessed with an index that is negative or greater than or equal to the array length.
The index used to access the array is outside the valid range [0, array.length - 1]. This can happen in loops with off-by-one errors, when using user input as indices, or when arrays are shorter than expected.
Check the array length before accessing elements. Fix loop bounds to use < array.length instead of <= array.length. Validate user input before using it as an index.
int[] arr = {1, 2};
arr[5]; // AIOOBEIllegalArgumentExceptionA method receives an argument that is not valid for its expected range or format.
NegativeArraySizeExceptionAn array is created with a negative size.
NullPointerExceptionA null reference is used where an object is required.
UnknownHostExceptionThe hostname cannot be resolved to an IP address.
NoSuchElementExceptionAn attempt to retrieve an element from an empty collection or exhausted iterator.
OutOfMemoryErrorThe JVM has exhausted its available heap memory.