Getters and setters

In Kotlin any class can have a property, basically a member data in Java language. And for property having the getters and setters is optional. If you have any specific behavior or actions to perform while getting or setting the value, then having getters and setters makes sense and it can be performed as shown previously.

Get Kotlin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.