Results 1 to 4 of 4
Thread: Exception handling
- 03-25-2012, 07:35 AM #1
Member
- Join Date
- Mar 2012
- Posts
- 10
- Rep Power
- 0
- 03-25-2012, 08:01 AM #2
Re: Exception handling
when using throws keyword you are telling the JVM that the exception that if occurred in the current method should be sent to the calling method and the caller must handle the exception.
on the other hand throw keyword allows you to manually generate objects of Exception or its Subclasses and throw them back to the caller.
Using throw you can generate your custom exceptions(user defined) and send them back to caller
they are used as :
Java Code:public void someMethod throws MyException{ if(condition){ throw new MyException(); } }
- 03-25-2012, 08:01 AM #3
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Re: Exception handling
The throws keyword use in the method declaration to tell that the method throws some type of exception. While the throw keyword is used to throw the actual exception from a method.
Website: Learn Java by Examples
- 03-25-2012, 08:07 AM #4
Member
- Join Date
- Mar 2012
- Posts
- 10
- Rep Power
- 0
Similar Threads
-
exception handling
By niksipandit in forum New To JavaReplies: 3Last Post: 09-22-2011, 02:25 PM -
Exception handling
By herat in forum New To JavaReplies: 1Last Post: 06-21-2011, 10:13 AM -
Exception Handling
By link6790 in forum New To JavaReplies: 16Last Post: 05-19-2011, 06:57 PM -
Exception Handling
By liljester in forum New To JavaReplies: 4Last Post: 06-21-2010, 03:09 PM -
Exception Handling...
By focus_nitin in forum New To JavaReplies: 1Last Post: 02-16-2008, 03:13 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks