Carino sto giochetto, però con un codice leggibile diventa anche più accattivante
Codice PHP:
class ColorException extends Exception {}
class WhiteException extends ColorException {}
public class White
{
void m1() throws ColorException
{
throw new WhiteException();
}
void m2() throws WhiteException
{
}
public static void main (String[] args)
{
White white = new White();
int a,b,d,f;
a = b = d = f = 0;
try
{
white.m1();
a++;
}
catch (ColorException e)
{
b++;
}
try
{
white.m2();
d++;
}
catch (WhiteException e)
{
f++;
}
System.out.print(a+","+b+","+d+","+f);
}
}
Il fatto è che m2 può lanciare eccezioni, ma non è mica obbligato a farlo! Anzi, se guardi cosa fa m2 ti accorgi che non fa proprio nulla....
edit...
Azz, ho perso troppo tempo... beh, ormai lascio