Can we write try catch inside constructor?? Binary Search
Utilisateur anonyme
Yes we can write try catch block in constructor and it does work properly. class a { a() { try { int b=5/0; }catch(Exception e) { System.out.println(e); } } output : java.lang.ArithmeticException: / by zero public static void main(String args[]) { a a1=new a(); } }