Professional Documents
Culture Documents
Diff Throw Throws Throwable
Diff Throw Throws Throwable
and Throwable?
• In Java, all error's and execption's class are drieved from java.lang.Throwable class. It is the
top of the hierarchy of classes of error and exceptions. Only objects that are instances of this
class (or one of its subclasses) are thrown by the Java Virtual Machine or can be thrown by
the Java throw statement.
• throws is a post-method modifier and specifies which execptions may be thrown by the
method. If they are checked exceptions, the compiler will guarantee the code invoking that
method must catch these checked exceptions.
• throw statement is used to throw an error or exceptions. throw statement requires a single
argument: a instance of any subclass of the Throwable class or Throwable class. Executing
throw statement triggers the JVM to throw this exception and causes an exception to occur.