Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A method can return an Exception .is it correct?

 
wei liu
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A method can return an Exception .is it correct?
 
Rashmi Tambe
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya why not ! A method can return any type of object or primitive type or none(void). An Exception is an object...so can be returned from the method provided the method prototype shd declare the required return type.
HTH
Rashmi
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's true; there's nothing about this compiler cares about:

But I'm pretty that's not the actual question; or if it is, that the learning point behind it is a rather obscure one.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic