Home Help Java T throw Java Keyword



throw Java Keyword
Posted on: November 18, 2009 at 12:00 AM
"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");
}

}}
 

Related Tags for throw Java Keyword:


More Tutorials from this section

Ask Questions?    Discuss: throw Java Keyword  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.