The difference between [Java] throw and throws face questions of

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/jhl19981125/article/details/102756801

The difference between the throw and throws

the throw:
(. 1) the throw statement is used in vivo, represents an exception is thrown by the method of in vivo processing of the statement.
(2) specific throw thrown outwardly operation, so that it throws an exception instance, must be performed throw thrown some abnormality.
throws:
(1) throws statement is used in the method behind the statement, said that if an exception is thrown, to exception handling by the caller of the method.
(2) throws primarily declare this method throws an exception of some kind, it's the user needs to know the type of exception caught.
(3) throws represent a possibility abnormal does not necessarily happen this anomaly.

Guess you like

Origin blog.csdn.net/jhl19981125/article/details/102756801