Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

What is the difference between throw and throws ?
The throw keyword is used to throwing the exception
manually in the program. For Example:

try{
throw new NullPointerException();
}catch(NullPointerException e){
}

The throws keyword is used with the method signature 
with the list of Exceptions type. This process is called 
exception declaration. It tells the calling method to 
guard themselves to declare the exception or handle it. 
For example:

void calculate(int a,int b) throws ArithematicException{
//some calculation code here
}