MATLAB BUILDER JA 2 Guida Utente Pagina 69

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 292
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 68
Handling Errors
y = cls.myprimes(1, new Double((double)n));
return (double[])((MWArray)y[0]).getData();
}
/* Catches the exception thrown by anyone */
catch (Exception e)
{
System.out.println("Exception: " + e.toString());
return new double[0];
}
finally
{
MWArray.disposeArray(y);
if (cls != null)
cls.dispose();
}
}
Code Fragment: Catching Multiple Exception Types
This second, and more general, variant of this example diffe rentiates between
an exce ption generated in a compiled method call and all other exception
types by introducing two
catch clauses as follows:
public double[] getprimes(int n)
{
myclass cls = null;
Object[] y = null;
try
{
cls = new myclass();
y = cls.myprimes(1, new Double((double)n));
return (double[])((MWArray)y[0]).getData();
}
/* Catches the exception thrown by myprimes */
catch (MWException e)
{
3-23
Vedere la pagina 68
1 2 ... 64 65 66 67 68 69 70 71 72 73 74 ... 291 292

Commenti su questo manuale

Nessun commento