permaculture playing cards*
The moose likes Beginning Java and the fly likes core java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "core java" Watch "core java" New topic
Author

core java

vijay deivasigamani deivasigamani
Greenhorn

Joined: Apr 15, 2007
Posts: 3
Hi,

I have a doubt, can we return an exception to a method? if so give me an example.
Jim Hardin
Ranch Hand

Joined: Aug 02, 2006
Posts: 46
I think this question belongs in "Java >> Java in General (beginner)"
instead of "Products >> Struts". That said, if I understand your question, I think you're looking for:

See also Sun Exceptions Tutorial.
-Jim
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Yes, a method can return any type, also an Exception.

This:

returns an Exception, but it does not throw one. Output is
java.lang.Exception: Eeks !


Yours,
Bu.


all events occur in real time
vijay deivasigamani deivasigamani
Greenhorn

Joined: Apr 15, 2007
Posts: 3
Hi Burkhard Hassel , Jim Hardin

Thanks for your reply and cleared with the doubt.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: core java