In Java, getter and setter are two conventional methods that are used for retrieving and updating the value of a variable.
The following code is an example of a class with a private variable and few getter/setter methods:
public class GetterAndSetter
 {
    private int num;
 
    public int getNumber()
   {
        return this.num;
    }
 
    public void setNumber(int number)
  {
        this.num = number;
   }
}