The exception is never shown .
extended Exception
class and override the method toString
.and then called it.according to the condition it should display hahah , but it doesn't show anything..no errors either.
class Excp extends Exception {
public String toString() {
return "hahah";
}
}
public class exc {
boolean a = false;
void hey() throws Excp {
if (a)
throw new Excp();
}
public static void main(String... s) {
try {
new exc().hey();
} catch (Excp e) {
System.out.println(e);
}
}
}