![]() ![]() If anything is marked as internal, then that specific field will be in the internal field. Internal is a newly added modifier introduced in Kotlin. ![]() In the above example, the variable “i” is declared as protected, hence, it is only visible to its subclass. A protected class or interface is visible to its subclass only. Protected is another access modifier for Kotlin, which is currently not available for top level declaration like any package cannot be protected. In the above example, the class “privateExample” and the variable i both can be accessible only in the same Kotlin file, where its mentioned as they all are declared as private in the declaration block. A private class or interface can be accessible only by its data members, etc. For instance, a private package can be accessible within that specific file. Once anything is declared as private, then it will be accessible within its immediate scope. The classes, methods, and packages can be declared with a private modifier. There are four access modifiers available in Kotlin. Like other OOP programming language, this modifier is applicable at multiple places such as in the class header or method declaration. ![]() Access modifier is used to restrict the usage of the variables, methods and class used in the application. In this chapter, we will learn about different modifiers available in Kotlin language. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |