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

Da WikiSitech.
Vai alla navigazioneVai alla ricerca
 
(Una versione intermedia di uno stesso utente non è mostrata)
Riga 1: Riga 1:
 +
[[Programmazione:Java|<< Back to Java]]
 +
 
{| cellspacing=2 width="100%"
 
{| cellspacing=2 width="100%"
 
=Exception=
 
=Exception=
Riga 5: Riga 7:
 
|- valign="top"
 
|- valign="top"
 
|width="50%"|
 
|width="50%"|
 +
'''Bad Practice'''
 
<code java>
 
<code java>
 
void function() {
 
void function() {
Riga 11: Riga 14:
 
</code>
 
</code>
 
|valign="top" |
 
|valign="top" |
 +
'''Best Practice'''
 
<code java>
 
<code java>
 
void function() throws CheckedException{
 
void function() throws CheckedException{

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

}