MATLAB BUILDER JA 2 Betriebsanweisung Seite 69

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 292
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 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
Seitenansicht 68
1 2 ... 64 65 66 67 68 69 70 71 72 73 74 ... 291 292

Kommentare zu diesen Handbüchern

Keine Kommentare