官术网_书友最值得收藏!

Packages

Packages allow us to split classes and interfaces into separate namespaces. A package may contain any number of classes and interfaces. Any file may begin with a package declaration:

    package com.packt.myproject 
    class Foo 
    fun bar(): String = "bar" 

The package name is used to give us the fully qualified name (FQN) for a class, object, interface, or function. In the preceding example, the Foo class has the fully qualified name of com.packt.myproject.Foo, and the top-level bar function has the fully qualified name of com.packt.myproject.bar.

Kotlin differs from Java in that the directory structure does not have to match the package name. For example, in Java, a  com.packt.Foo class must reside in a file such as ./com/packt/Foo.java. Kotlin does not have this restriction.
主站蜘蛛池模板: 宿松县| 隆安县| 射洪县| 瑞安市| 金川县| 晋宁县| 侯马市| 林口县| 肇源县| 宝应县| 社旗县| 玉山县| 无棣县| 阿合奇县| 吉木乃县| 平安县| 祥云县| 永仁县| 洪江市| 招远市| 嘉定区| 武乡县| 城固县| 赣州市| 本溪市| 武威市| 灵山县| 中西区| 龙岩市| 广灵县| 黔西县| 岳西县| 桂阳县| 巴青县| 化德县| 阆中市| 夏津县| 屏东县| 永新县| 随州市| 巢湖市|