The following program will get the error of
unreported exception Exception; must be caught or declared to be thrown
Why the re-throw is not working? In C#, there is no need to wrap the call in try
block.
public class HelloWorld{
public static double test() throws Exception {
return 1;
}
public static void main(String []args){
try {
double a = test();
System.out.println(a);
}
catch (Exception e) {
throw e;
}
}
}