+ Start a Discussion

setter and getter methods

i am new to salesforce, i want to know the set and get method ...
what would happen when we declare the variables like this..
please kindly help me.. please.........

public Cat3__c cat {get;set;}
public String message {get;set;}

Ravikant kediaRavikant kedia
Setter and getter method are used to set and get value from viual force page.
Setter Methods:
<apex:inputText value= "{!message }"  />
Then when you enter value inside it then it will automaticaly set in controller message like in your public String message {get;set;} 

Getter Method;
When you declare value like message = 'test'; In your constructor or elsewhere in your controller then visualforce page auomaticaly get the value of message.

<apex:outputText value= "{!message }" /> 
NagaNaga (Salesforce Developers) 
Hi Anji Reddy,

Please follow the below link for more info on 


Please let me know if this helps you.

Best Regards
Naga Kiran