-
Junior Member
Can we use throw alone
Can we use throw method without using try in any place of code? and can anyone tell me what is the difference between throw and throws?
-
Contributing Member
Re: Can we use throw alone
Hi,
Yes. You can use throw alone without using try catch.
EG:
public void foo() throws Exception {
throw new Exception();
}
Throw is used to throw an exception.
Throws is used in a method declaration which says that this function throws an exception.
Hope this helps.
Regards,
Sahil.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules