У нас вы можете посмотреть бесплатно Visibility Modifier in Kotlin - public, private, protected, internal. Access Modifiers in Kotlin или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
In Kotlin, access modifiers (also known as visibility modifiers) are keywords used to restrict the scope and accessibility of classes, functions, properties, and constructors. The Four Access Modifiers Kotlin uses four modifiers, with public being the default if none is specified. 1. public - Default, visible everywhere. 2. private - Visible only within the containing file or class. 3. internal - Visible to any client within the same module. 4. protected - Visible in the class and its subclasses. What happens if a function is private in a class? In Kotlin: private members of a class are accessible ONLY inside that class’s body. That’s it. No subclasses. No objects. No same package. Can a subclass access a private function? NO — NEVER Why? private means not inherited The subclass does not even know the function exists Private members are NOT part of inheritance Can an object of the same class access a private function? NO In Java, this is allowed. In Kotlin, it is NOT allowed. Kotlin Rule: private means “this instance only”, not “same class type” But wait — when IS private accessible? Only inside the same class instance Why Kotlin does this (Design Reason) Kotlin enforces strong encapsulation. It avoids: Object-to-object spying Accidental misuse Tight coupling A module and a package are not the same. They operate at different levels of code organization. What is a Package? A package is a logical grouping of related classes and functions, similar to a folder on your computer. Purpose: It prevents naming conflicts (e.g., you can have two User classes if they are in different packages). Declaration: Defined at the top of a Kotlin file using the package keyword. Scope: Visibility modifiers like private can restrict access to the same file, but Kotlin does not have a "package-private" modifier like Java does. What is a Module? A module is a set of Kotlin files that are compiled together. It is a higher-level container that often includes many packages. Definition: A module is typically a single Gradle project, a Maven module, or an IntelliJ IDEA module. Access Control: This is where the internal modifier comes in. Anything marked internal is visible to every file in that module but hidden from any other module that uses it as a dependency. Telegram Group: https://t.me/androidNinjaWarrior Guide to watch: 00:00 Visibility Modifiers in Kotlin - public, private, protected, internal 20:25 Package vs Module in Kotlin #visibility #visibilityModifier #Access #AccessModifier #public #private #protected #internal #package #module #ProtectData #KotlinModifier #Modifiers #ModifiersInKotlin Disclaimer- Some content are used for educational purposes under fair use. Copyright Disclaimer Under Section 107 of the Copyright Act 1976, allowance is made for "fair use" for purposes such as criticism, comment, news reporting, teaching, scholarship, and research. Fair use is a use permitted by copyright statute that might otherwise be infringing. Non-profit, educational, or personal use tips the balance in favor of fair use. All credit for copyright material used in the video goes to the respected Owner. Thank you guys.