throws is used to specify that an exception/s can be thrown. Specifying is more pertinent to checked exceptions.
throw is simply the statement to manually/programically throw the exception or any object of throwable type.
Using throws
a method, and then tell that this method throws following exception…and then write da .. da .. da. Eg.
public void myMethod() throws MalformedURLException,MyCustomException1
{
//do something in method
}
Using throw
throw just throws exception. Eg.
if(something)
throw someObjectOfThrowableType
No comments:
Post a Comment