All right,
From what I understand, We use try/catch while we deal with a code that may throw exception
But We use throw when we want the code throws exception, right now!
and there is a catch clause for this exception that throws by "throw keyword" explicitly .
I saw these codes in wikipedia:
As you, the throw keyword is used now in catch clause.
How the exception throws in this caught?
When is it necessary to use throw in a catch clause?
This is what I understand:
You have a code that might throw exception, You put this code in try clause, Then exception caught by catch clause.
But there are sometimes that you need throw exception explicitly,then you use throw key
word, and there is a catch clause that waaits to process this exception.Then, the throw key word must not be in a catch, It must be out of catch.
Please correct me If I'm wrong