Visibility Modifiers
A brief rundown on visibility modifiers in Kotlin, with an emphasis on internal
and what a module is
— — — — — — — — — — — — — — —
THE CURRENT VERSION OF THIS ARTICLE IS PUBLISHED HERE.
— — — — — — — — — — — — — — —
Tags: #FYI
This article is part of the Kotlin Primer, an opinionated guide to the Kotlin language, which is indented to help facilitate Kotlin adoption inside Java-centric organizations. It was originally written as an organizational learning resource for Etnetera a.s. and I would like to express my sincere gratitude for their support.
It is recommended to read the Introduction before moving on. Check out the Table of Contents for all articles.
This is pretty boring, so let’s get it over with. Classes, objects, interfaces, constructors, functions, properties and their setters can have visibility modifiers. Getters always have the same visibility as the property.
There are four visibility modifiers in Kotlin: private
, protected
, internal
and public
. The default visibility is public
. Kotlin does not have package private visibility, a decision which is actively debated.