What Is Getter And Setter Methods In Salesforce?
Getter and Setter methods are used to get and set the value of properties of a class, respectively. Here is the below example sample code for getter Setter methods.
How To Use Getter And Setter In Salesforce?
public class MyClass {
private String myProperty;
public String getMyProperty() {
return myProperty;
}
public void setMyProperty(String value) {
myProperty = value;
}
}
In the above code, setMyProperty method is used to set the myProperty property value. getMyProperty method is used to get the myProperty value.