You need to sign in to do that
Don't have an account?
Chandramohan Yetukuri 1
I have one basic question...what is the significance of get and set in the code.
Hi Friends,
I have the below line something like this in one of the apex classs..
public String productCode {get;set;}
What is the impact if i remove {get;set;} and simply keep like this......"public String productCode"
Can someone explain.
Regards,
Chandra
I have the below line something like this in one of the apex classs..
public String productCode {get;set;}
What is the impact if i remove {get;set;} and simply keep like this......"public String productCode"
Can someone explain.
Regards,
Chandra
A variable becomes a property when we define with 'get, set' methods. otherwise it remains as a member variable.
The main advantage of defining a variable as property is
- you can add some validation while getting or setting the data in get/set method
- you can make it read only or write only by defining either get or set method only respectively.
Please refer,https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_properties.htm
Please mark it as solved if this answers your question.
Thanks.