Catching Exceptions
try {
}
catch(Exception e) {
}
Common Exceptions
Class IndexOutOfBoundsException
import java.lang.IndexOutOfBoundsException;
throw new IndexOutOfBoundsException(); //option 1
throw new IndexOutOfBoundsException("optional message"); //option 2
Class ArithmeticException
import java.lang.ArithmeticException
throw new ArithmeticException() //option 1
throw new ArithmeticException("optional message") //option 2
Class NoSuchElementException
import java.util.NoSuchElementException
throw new NoSuchElementException() //option 1
throw new NoSuchElementException("optional message") //option 2
Class java.io.FileNotFoundException
import java.util.NoSuchElementException
throw new FileNotFoundException() //option 1
throw new FileNotFoundException("optional message") //option 2