Share on Google+Share on Google+

throw Java Keyword

"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.


public class Class1{

public method readtheFile(String file) throws IOException{


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




Posted on: November 18, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

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.

Discuss: throw Java Keyword  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
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.