Differenze tra le versioni di "Programmazione:Java/Exception"

Da WikiSitech.
Vai alla navigazioneVai alla ricerca
 
 
(2 versioni intermedie di uno stesso utente non sono mostrate)
Riga 1: Riga 1:
 +
[[Programmazione:Java|<< Back to Java]]
 +
 
{| cellspacing=2 width="100%"
 
{| cellspacing=2 width="100%"
 
=Exception=
 
=Exception=
  
 
Usare eccezioni '''checked''' per essere sicuro che qualcuno le intercetti
 
Usare eccezioni '''checked''' per essere sicuro che qualcuno le intercetti
 
 
|- valign="top"
 
|- valign="top"
 
|width="50%"|
 
|width="50%"|
 
+
'''Bad Practice'''
 
<code java>
 
<code java>
 
void function() {
 
void function() {
Riga 12: Riga 13:
 
}
 
}
 
</code>
 
</code>
 
 
|valign="top" |
 
|valign="top" |
 
+
'''Best Practice'''
 
<code java>
 
<code java>
 
void function() throws CheckedException{
 
void function() throws CheckedException{
Riga 20: Riga 20:
 
}
 
}
 
</code>
 
</code>
 
 
|}
 
|}

Versione attuale delle 10:31, 14 apr 2008

<< Back to Java

Exception

Usare eccezioni checked per essere sicuro che qualcuno le intercetti

Bad Practice void function() {

  throw new RuntimeException("");

}

Best Practice void function() throws CheckedException{

  throw new CheckedException("");

}