- Learn Kotlin Programming(Second Edition)
- Stephen Samuel Stefan Bocutiu
- 210字
- 2021-06-24 14:13:32
Access levels
All types and type members have accessibility levels, which constrain where they can be used. As mentioned earlier, not specifying the access level defaults to public. Kotlin comes with three different access levels, which are as follows:
- Internal: This means you can create a new instance of your class from anywhere within your module
- Private: This is more restrictive than the previous one because a class is only visible in the scope of the file defining it
- Protected: You can use this accessibility level only for subclasses; it is not available for the file-level type of declaration
This differs from Java, which does not offer internal, and defaults to package-private.
The internal access level is the equivalent of private for classes when it comes to encapsulation; only this time it is at the module level. A class, interface, and so on can be made visible at the module level if the code isn't accessed from outside the module—for example, if the code is used purely for internal logic. This reduces the API you expose and makes it easier to understand. Furthermore, if a change is required in your module, you can assume that modifying the contract will only break the internal API of the assembly.
- Unity 2020 By Example
- Functional Python Programming
- jQuery Mobile Web Development Essentials(Third Edition)
- 從零開始:數(shù)字圖像處理的編程基礎(chǔ)與應(yīng)用
- Oracle 11g從入門到精通(第2版) (軟件開發(fā)視頻大講堂)
- The Android Game Developer's Handbook
- Power Up Your PowToon Studio Project
- Cassandra Design Patterns(Second Edition)
- Python高效開發(fā)實(shí)戰(zhàn):Django、Tornado、Flask、Twisted(第2版)
- Python全棧數(shù)據(jù)工程師養(yǎng)成攻略(視頻講解版)
- Access 2010中文版項(xiàng)目教程
- Unity 3D腳本編程:使用C#語言開發(fā)跨平臺游戲
- Hands-On Neural Network Programming with C#
- Learning Splunk Web Framework
- Learning VMware vSphere