MATLAB BUILDER JA 2 Guide de l'utilisateur Page 69

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 292
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 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
Vue de la page 68
1 2 ... 64 65 66 67 68 69 70 71 72 73 74 ... 291 292

Commentaires sur ces manuels

Pas de commentaire