Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Help Java T throw Java Keyword

Related Tutorials


 
 

Share on Google+Share on Google+

throw Java Keyword

Advertisement
"throw " is a keyword defined in the java programming language.

throw Java Keyword

     

"throw " is a keyword defined in the java programming language. Keywords are basically reserved words which have specific meaning relevant to a compiler in java programming language likewise the throw keyword indicates the following :

-- The throw keyword in java programming language is used to throw an exception.
-- The throw statement in java programming language takes the object of the class  java.lang.Throwable as an argument. This Throwable is propagates up the
call stack till it is caught by an appropriate catch block lying among the multiple catch blocks.
-- If any method throws an exception which is not a RuntimeException, then it must be declared in advance to handle the exceptions it throws using a throws modifier on the method declaration.

import java.io.IOException;

public class Class1{

public method readtheFile(String file) throws IOException{

<statements>
<statements>
<statements>
 

if (error){
throw new IOException("error reading file");
}

}}
 

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 18, 2009

Related Tutorials

Discuss: throw Java Keyword  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
shailesh
October 31, 2012
throw Java Keyword

sir please explain me throw keyword program using easy technique now i am in syit class .i am not getting understand about throw keyword example.
DMCA.com