This is my code
static void tryit() throws Exception
{
System.out.println(10 / 0);
}
public static void main(String[] args)
{
try {
tryit();
} catch (Exception e) {
System.out.println("Exception caught in main");
}
}
here what am wandering is, in line 1 of this code throws Exception
what exactly does?
Even if I didn't use that also I got same output as
Output : Exception caught in main
Where it will be effective? Is it necessary in this code?