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

Home Help Java T throws Java Keyword

Related Tutorials


Share on Google+Share on Google+

throws Java Keyword

throws " is a keyword defined in the java programming language.

throws Java Keyword


throws " 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 throws keyword in java programming language is applicable to a method to indicate that the method raises particular type of exception while being processed.
-- The throws keyword in java programming language takes arguments as a  list of the objects of type java.lang.Throwables class.
-- when we use the throws with a method it is known as ducking. The  method calling a method with a throws clause is needed to be enclosed within the try catch blocks.

Example to use the throws keyword in a class:


public class Class1{

public method readingFile(String file) throws IOException{


if (error){

throw new IOException("error reading file");


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: throws Java Keyword   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
November 16, 2011
throw and throws is a keyword or class?

pls give reply
March 5, 2012

What is the main use of throw & throws keywords in java..?