Getter and Setters

Learn how to read and write properties using getters and setters.

Introduction

Getters and setters are special methods that provide read and write access to an object’s properties. Recall how we were able to retrieve and set the values of instance variables using the dot operator (.). Each instance variable has an implicit getter and setter which we have been using up until now. In this lesson, we will explore the getter and setter methods.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy