You need to sign in to do that
Don't have an account?
Nidhi Malhotra
Why are get set method used?
Hi All,
Could you please help me to let me know why get and set is used in Salesforce Apex? And how is it used and how gettter and setter methods are defined and even the differences.
Thanks,
Nidhi
Could you please help me to let me know why get and set is used in Salesforce Apex? And how is it used and how gettter and setter methods are defined and even the differences.
Thanks,
Nidhi
Get methods are used to initialize a property(variable) in a class such that when a visualforce page calls that property - it can display its value on the vf page
Set methods are used to assign a new value to the property :
Read though the examples in the below doc :
http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_methods.htm
All Answers
public String tectV {get; set;}
This means, you can use this variable on page to get the value from controller as well as set value from page. This is similar to bean concept in java.
The below KB article will explain more about this
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_properties.htm
Get methods are used to initialize a property(variable) in a class such that when a visualforce page calls that property - it can display its value on the vf page
Set methods are used to assign a new value to the property :
Read though the examples in the below doc :
http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_methods.htm