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

Da WikiSitech.
Vai alla navigazioneVai alla ricerca
Riga 5: Riga 5:
 
|- valign="top"
 
|- valign="top"
 
|width="50%"|
 
|width="50%"|
 +
'''Bad Practice'''
 
<code java>
 
<code java>
 
void function() {
 
void function() {
Riga 11: Riga 12:
 
</code>
 
</code>
 
|valign="top" |
 
|valign="top" |
 +
'''Best Practice'''
 
<code java>
 
<code java>
 
void function() throws CheckedException{
 
void function() throws CheckedException{

Versione delle 12:25, 31 ott 2007

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("");

}