![]() ![]() You will not be able to access internal members outside the module. Internal members are accessible to classes with the same module. Protected var empId: Int = 0 Internal modifier In the below example, we declared variable empId with protected access modifier. You will not be able to access protected members outside of class, however, you can access them in subclass and further subclasses in the hierarchy. Protected members are only visible in class and subclass. Private var empId: Int = 0 Protected modifier ![]() In the below example, we declared variable empId with private access modifier. You will not be able to access private members outside of class, even in a subclass. ![]() Private members are only accessible within the class. This isn't exactly a security feature, but it provides a good guidance to other developers in object oriented design, as in they know what is the intent of your class design and modify their usage accordingly.įor classes and interface methods Kotlin provide the following access modifiers. It is used to control access to data elements and methods in your class. Access modifiers do exactly what the name suggests. ![]()
0 Comments
Leave a Reply. |