Throw And Throws In Java
throw:
throw is used in re-throwing exception process or we can say that it is used to throw an exception object explicitly. It can take at most one argument which will be an exception object. Only unchecked exception can be thrown.
throws:
throws keyword is used to throw an exception object implicitly. The throws keyword is used with the method signature. We can declare more than one type of exceptions with method signature which should be comma separated.
Note:
1. throws is commonly used to throw checked exception.
2. If we are calling a method that declares an exception then we must have to either caught or declare the exception.
3. Exception can be re-thrown.
https://cjavapoint.blogspot.com/?m=1
throw:
throw is used in re-throwing exception process or we can say that it is used to throw an exception object explicitly. It can take at most one argument which will be an exception object. Only unchecked exception can be thrown.
throws:
throws keyword is used to throw an exception object implicitly. The throws keyword is used with the method signature. We can declare more than one type of exceptions with method signature which should be comma separated.
Note:
1. throws is commonly used to throw checked exception.
2. If we are calling a method that declares an exception then we must have to either caught or declare the exception.
3. Exception can be re-thrown.
https://cjavapoint.blogspot.com/?m=1
Blogspot
Core Java Interview Questions - Learn Java
Java Tutorial or Learn Java or Core Java Tutorial or Java Programming Tutorials for beginners and professionals with core concepts and examples