Algus

Visibility Modifiers

Classes, objects, interfaces, constructors, and functions, as well as properties and their setters, can have visibility modifiers.

💡 Getters always have the same visibility as their properties.

There are four visibility modifiers in Kotlin: privateprotectedinternal, and public. The default visibility is public.

Packages

// file name: example.kt
package foo

private fun foo() { ... } // visible inside example.kt

public var bar: Int = 5 // property is visible everywhere
    private set         // setter is visible only in example.kt

internal val baz = 6    // visible inside the same module

Class members