answersLogoWhite

0

The throw keyword is used from within a method to "throw" an exception to the calling method. In order to throw an exception, the method signature must indicate that it will throw an exception. For example: public void foo() throws Exception { } When you want to actually throw the exception, you can do it a few different ways: throw new Exception("Exception message"); or from within a catch block ( catch(Exception ex) ): throw ex;

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

How do you throw exception in java?

we do it using the throw keyword.


What keyword are used in java for exception handling?

The important keywords used in Java with respect to Exception Handling are: a. Throw - The "throw" keyword is used to throw exceptions from inside a method b. Throws - The "throws" keyword is used to signify the fact that the code contents within the current method may be throwing an exception and the calling method must handle them appropriately


What is the difference between throw and throws in net?

"throw" is the keyword to raise an exception. "throws" is a Java keyword that indicates a specific method can potentially raise a named exception. There is no analog in VB.Net or C#. Perhaps there is a "throws" keyword in J#?


Is check a keyword in java?

No, 'check' is not a keyword in java language.


What types of values can be thrown in java?

Only instances of subclasses of throwable can be used in conjunction with the throw keyword. In java all exceptions and errors are subclasses of throwable.


Can NullPointerException be used with ArithmaticException using throws keyword in java?

No. You cannot throw or catch Null pointer exceptions


Is float is a keyword in java?

yes, float is keyword and data type in java


What does the verify keyword do in Java?

"verify" is not a Java keyword. I believe the link, in related links, has the complete list of Java keywords.


Why should throw keyword is used in java?

Use it when you are implementing something that says it throws a certain exception when a certain condition is met.


What is foreign keyword in java?

There is no "foreign" keyword in Java, however, there is a native keyword that declares native methods in a native language, such as C or C++.For full list of keywords in Java see related question.


When wil you need throws keyword in java?

The throws keyword will be used in method declaration to signify the fact that, some pieces of code inside the method may throw exceptions that are specified in the method signature.


What is literal in java programming?

Literal in java are L, F, null, true, false These act as keyword(have special meaning in java) but these does'nt comes under the category of Java Keyword.