Well, from a book i got the below lines:
Java defines several exception classes inside the standard package java.lang. The most general of these exceptions are subclasses of the standard type RuntimeException. Since java.lang is implicitly imported into all Java programs, most exceptions derived from RuntimeException are automatically available.
Furthermore, they need not to be included in any method's throws list.
So, doesnt it mean that i dont need a try catch block?
i have done the following code, but it showing error:
Exception in thread "main" java.lang.ArithmeticException: / by zero
at ArithCls.main(ArithCls.java:10)
Code:
import java.lang.*;
public class ArithCls {
public static void main(String[] args)
{
int a=20;
int b=0;
int c = a/b;
System.out.println("After code");
}
}