setter and getter methods.
3 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, February 28, 2006 07:34 AM

What is the need of setter and getter methods in beans?

Why can't we use normal methods.

Can any one explain me the internal mechanism(i.e., how and when these methods are going to be invoked)?
Thanks in advance.

Re: setter and getter methods.

Posted By:   pradeep_kumar  
Posted On:   Tuesday, February 28, 2006 07:47 AM


When the bean is deployed in the bean editor,the through this naminng pattern(getters and setters) the editor get to know which method to call when a property is changed through the default property editor(Through Introspection).



Basiclly they tells by default that which method to exceute when a particular property is changed Which otherwise cant be done by normal methods.

Re: setter and getter methods.

Posted By:   WarnerJan_Veldhuis  
Posted On:   Tuesday, February 28, 2006 07:43 AM

To clarify a bit more: an IDE knows how to handle setUsername(String name), not willYouPleaseSetThisNameToSomeUserPlease(String name)

Re: setter and getter methods.

Posted By:   WarnerJan_Veldhuis  
Posted On:   Tuesday, February 28, 2006 07:42 AM

Getters and setters ARE normal methods.


These methods are standardized, so you (or an IDE) can access them by reflection: A property String username has a corresponding getter/setter public String getUsername(){...} and public void setUsername(String name) {...}
About | Sitemap | Contact