The difference between throw and throws

Throw:

Act in the method, which means to throw a specific exception, which is handled by the statement in the method body.
The specific action that is thrown out, so it throws an abnormal entity class. If Throw is executed, some kind of exception must be thrown.

Throws:

Acting on the method declaration means that if an exception is thrown, the caller of the method will handle the exception.
The main statement is that this method will throw a certain type of exception, so that its users know the type of exception caught.
An abnormality is a possibility, but an abnormality does not necessarily occur.

Guess you like

Origin blog.csdn.net/NuanShuTT/article/details/108214057