/**
* {@link <a href=
* "https://[Log in to view URL]"
* target="_blank">Lancio di un'eccezione manuale :: throw</a>}
*
* @author itammb ( Italia Massimiliano Buscati )
* @version JDK 1.15
*
*/
class Main {
/**
* @see NullPointerException
*
*/
public static void applayThrow() throws NullPointerException {
try {
throw new NullPointerException("lancio eccezione manuale");
} catch (NullPointerException e) {
System.out.println("NullPointerException");
// ri-lancia l'eccezione al metodo precedente
throw e;
}
}
public static void main(String args[]) throws Exception {
// Unit test - lancio di un'eccezione manuale
try {
applayThrow();
} catch (NullPointerException e) {
System.out.println("NullPointerException");
}
System.out.println( "qui prosegue il flusso dopo un NullPointerException gestito" );
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: