throw keyword in java

The ‘throw’ keyword is used to throw an exception explicitly. When a throw statement is encountered and executed, execution of the further code is stopped and returned to the caller. The throw statement takes a java.lang.Throwable as an argument. The Throwable is propagated up the call stack until it is caught by an appropriate catch […]

Share this article on

throws keyword in java

The “throws” keyword can be applied to a method to indicate that, the method raises particular types of exceptions and it is not handling that exception. So this signals the caller that, It has to handle the exception thrown by the method. Example:  public class ReadFileExample  {         public method readFile(String filename) […]

Share this article on
< Previous Next >