Experience Salesforce

Getter, Setter Method Part 1

What You’ll Learn

  • What Is Getter And Setter Methods In Salesforce?
  • How To Use Getter And Setter In Salesforce?

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.

salesforce-developer
Next Topic

Need Extra Support? Our FREE study materials have got you covered.

Our expert-prepared study materials provide the answers you need. Clear your doubts and improve your skills with detailed notes from industry professionals.

cts-img
Rakshabandhan Sale