Throw exception in Java
问题 Suppose I have a class, the requirement is that "change the following code to throw checked exception if "den" is 0, and change the function to catch that exception". public class divide { void divide(int num, int den){ System.out.println(""+(num/den)); } void fun(){ divide(4,2); } } Which of the following one is the correct way to throw exception? Option 1: void divide(int num, int den) throws Exception{ if(den==0){ throw new Exception("Dividebyzero"); } System.out.println(""+(num/den)); }