Lançando exceção com o Throw
private static int dividir(int i, int j) throws Exception {
if (j == 0) {
throw new Exception("Não é possivel realizar divisão por zero.");
}
return i / j;
}Atualizado
private static int dividir(int i, int j) throws Exception {
if (j == 0) {
throw new Exception("Não é possivel realizar divisão por zero.");
}
return i / j;
}Atualizado