sintassi
modificatore_accesso static final tipo_valore NOME(parametri)
throws tipo_eccezione
{
if(base < 0)}throws new tipo_eccezione("testo");...
return x;
esempio: calcola area Parallelogramma con eccezioni se parametri negativi
public double areaParallelogramma(double base, double altezza)
throws IllegalArgumentException
{
if(base < 0)}throw new IllegalArgumentException("base negativa");
if(altezza < 0)throw new IllegalArgumentException("altezza negativa");
if(base == 0.0 || altezza == 0.0)return 0.0;
double a = base * altezza;
return a;