wood burning stoves 2.0*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 37891
    
  22
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.
 
wood burning stoves
 
subject: Is it dvisable to throw exceptions inside the setter mehods ?
 
Similar Threads
Question on Synchronized mehods
null as arg in mehods
clarification about InetAddress class and its mehods
Type inference in generic mehods