Question | ||||
| ||||
|
public class HelloWorld{
public static void main(String []args){
try{
System.out.println(1/0);
}
}
}
Above code gives "'try' without 'catch', 'finally' or resource declarations error"
public class HelloWorld{public static void main(String []args){try{System.out.println(1/0);}catch(Exception e){System.out.println("catch");}}}Above code compiles properlypublic class HelloWorld{public static void main(String []args){try{System.out.println("try");}finally{System.out.println("finally");}}}
Above code compiles properly