This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Is it dvisable to throw exceptions inside the setter mehods ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Is it dvisable to throw exceptions inside the setter mehods ?" Watch "Is it dvisable to throw exceptions inside the setter mehods ?" New topic
Author

Is it dvisable to throw exceptions inside the setter mehods ?

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Is it dvisable to throw exceptions inside the setter mehods ?

For example :



Thanks in advance.


Save India From Corruption - Anna Hazare.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43928
    
  33
Yes. Good idea.

But you should be circumspect about what sort of Exception you are throwing. I would enhance what you have written toNote that much of what I wrote is actually documentation comments, so users of that method know about the Exception.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it dvisable to throw exceptions inside the setter mehods ?
 
It's not a secret anymore!