Home  >  Forum  >  Core Java
Post New Query

exception handling in core java


joined on
November 05,2013
Asked on November 06,2013
what is the difference between the throws and throw. i have read from internet but the point is not clear to me.
joined on
March 14,2013
Replied on November 06,2013

throw : throws one exception object when desired anywhere in the program. Ex 
If(b==0){
  throw new Exception("Some error");
}

throws: throws keyword is used at method level. We can mention more than one exception type as comma separated and whatever exception will be applicable, will be thrown by method. Ex. 

public void cal() throws FileNotFoundException, MalformedURLException {} 
joined on
March 14,2013
Replied on November 06,2013

Write Answer








Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us