public class Main {
public static Main me;
public Main() throws Exception {
this.me = this;
throw new Exception("constructor error.");
}
public void method() {
System.out.println("It's me");
}
public static Main main() {
return me;
}
public static void main(String... args) {
try {
Main main = new Main();
} catch (Exception e) {
System.out.println("constructor failed.");
}
Main main = Main.main();
main.method();
}
}
result
constructor failed.
It's me
Recommended Posts