Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: Difference between throw and throws in Java Exception Handling

Started 1 month, 1 week ago by KALYAN23
I am learning Java . I reached the topic of exception handling in Java. I am not able to understand the exact difference between throw and throws with respect to exception handling in Java. What is the actual difference between the two ? What are the funtionality of each individual ? I am totally lost in this topic.
Site: TechArena Community - Technology and Computer Hardware Support Forums of India  TechArena Community - Technology and Computer Hardware Support Forums of India - site profile
Forum: Software Development  Software Development - forum profile
Total authors: 4 authors
Total thread posts: 4 posts
Thread activity: no new posts during last week
Domain info for: techarena.in

Other posts in this thread:

Reegan replied 1 month, 1 week ago
In very simple words, " throws " declares that the method is capable of throwing an exception while " throw " actually does the job of throwing the exception. They are not same. eg: Code: public void Exep(int param) throws MyException { if (param > 7) { throw new MyException("You have entered big value"); } . . . } Consider the above code. The keyword throws signifies that the ...

Modifier replied 1 month, 1 week ago
The keyword throw and throws are used for Exception handling in Java. Sun Microsystems developed Java has many feature of which is Exception Handling. Precisely a throw statement initiates an exception to be thrown, where as the throws clause declares that the method is expected to throw one or more checked execptions. Thus both are different and perform two different task.

Praetor replied 1 month, 1 week ago
The keyword throw in Java is used to raise exception explicitly that means it is used when a user defined exception is raised. The keyword throws in Java is a modifier of a method that is expected to generate and throw exception/s. Mostly methods which are capable of throwing an exception but not handling are specified with throws keyword.

 

Top contributing authors

Name
Posts
KALYAN23
1
user's latest post:
Difference between throw and...
Published (2009-11-09 21:09:00)
I am learning Java . I reached the topic of exception handling in Java. I am not able to understand the exact difference between throw and throws with respect to exception handling in Java. What is the actual difference between the two ? What are the funtionality of each individual ? I am totally lost in this topic.
Reegan
1
user's latest post:
Difference between throw and...
Published (2009-11-09 21:09:00)
In very simple words, " throws " declares that the method is capable of throwing an exception while " throw " actually does the job of throwing the exception. They are not same. eg: Code: public void Exep(int param) throws MyException { if (param > 7) { throw new MyException("You have entered big value"); } . . . } Consider the above code. The keyword throws signifies that the...
Modifier
1
user's latest post:
Difference between throw and...
Published (2009-11-09 21:09:00)
The keyword throw and throws are used for Exception handling in Java. Sun Microsystems developed Java has many feature of which is Exception Handling. Precisely a throw statement initiates an exception to be thrown, where as the throws clause declares that the method is expected to throw one or more checked execptions. Thus both are different and perform two different task.
Praetor
1
user's latest post:
Difference between throw and...
Published (2009-11-09 21:09:00)
The keyword throw in Java is used to raise exception explicitly that means it is used when a user defined exception is raised. The keyword throws in Java is a modifier of a method that is expected to generate and throw exception/s. Mostly methods which are capable of throwing an exception but not handling are specified with throws keyword.

Related threads on "TechArena Community - Technology and Computer Hardware Support Forums of India":

Related threads on other sites:

Thread profile page for "Difference between throw and throws in Java Exception Handling" on http://www.techarena.in. This report page is a snippet summary view from a single thread "Difference between throw and throws in Java Exception Handling", located on the Message Board at http://www.techarena.in. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity