Getter

A method or property part that reads a value from an object.

What is Getter?

A getter is a method (or property part) that returns a value from an object. It lets outside code read data without touching the private field directly.

public class Thermostat
{
    private int temperature = 20;
    public int Temperature { get => temperature; }  // getter
}

Level: Apprentice · More OOP terms at this level

Updated

In other subjects