Setters and Getters

Let's discuss the use of setters and getters in packages in this lesson.

We'll cover the following

Setters

In order to assign a value to a member variable of an object after it has been instantiated, we define a setter. Let’s implement setter methods for the package Shape to set the name and sides of the shape.

Create a free account to access the full course.

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