/**
* {@link <a href=
* "https://[Log in to view URL]"
* target="_blank">Assertions</a>}
*
* @author itammb ( Italia Massimiliano Buscati )
* @version JDK 1.15
*
*/
class Main {
/**
* @see RuntimeException
*
*/
public static void applayVMError() {
int a = 1;
if (a != 0)
throw new RuntimeException("RuntimeException");
}
public static void applayAssert() {
int a = 1;
// impostare il parametro della VM -> -ea
// stampa sullo standard di output se il criterio è falso
assert a == 0 : "a != 0";
}
public static void main(String args[]) throws Exception {
// Unit test - lancia un errore in run-time
applayVMError();
// Unit test - lancia un assert in run-time
applayAssert();
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: