Difference between throw and throws The throw key word is used to explicitly throw an exception, while throws is utilized to handle checked exceptions for re-intimating the compiler that exceptions are being handled. It is kind of communicating to the compiler that an exception is expected to throw one or more checked exceptions.
The throws need to be used in the method’s definition and also while invoking the method that raises checked exceptions.
|