So I'm just starting to learn about Exception handling and I'm by something in the output of this code, So I wanted to check if I was going to get an arithmetic Exception if I did not "throws" the right class for the exception that will occur in the method num, in this case division by 0 .
public static void num(int k)//throws Exception
{
int ll = k /0;
}
public static void main(String [] args) {
Scanner in = new Scanner (System.in) ;
try {
num(2) ;
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
}
catch (Exception e) {
System.out.println("Handled");
}
The exception is still being caught by catch in the main even though I did not use "Throws " in the method num. I'm so confused to why this is happening, What would be the point of throws if I can still handle the exception regardless