
Internal - Internal marked declarations are visible inside the same module. They can be used in different files, classes, packages, etc. It means that the declarations are visible everywhere. Public - It is a default modifier and can be omitted. They are present directly inside any Kotlin file.įor top-level fields, the different visibility modifiers mean:

Top-level fields are those that are placed outside the classes or interfaces. The visibility modifiers have different meanings according to the place where they are placed. It means if we haven't specified any visibility modifier for a class, function, property etc then by default the compiler will consider it as public. The default visibility modifier is public. There are four visibility modifiers in Kotlin: Getters have the same visibility as the property.

In Kotlin, visibility modifiers can be applied to classes, constructors, objects, interfaces, functions, properties, and their setters. Visibility modifier keywords restricts the use of classes, functions, properties etc and states whether they are available in their subclasses, in other files, classes, other packages or not. Access modifiers or visibility modifiers are used to define the scope of a class, function, field, interface etc.

In this tutorial, we will cover visibility modifiers or access modifiers in Kotlin.
