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

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.
主站蜘蛛池模板: 西充县| 来宾市| 光山县| 梓潼县| 中方县| 泉州市| 铜山县| 香格里拉县| 应用必备| 咸阳市| 海伦市| 南岸区| 密山市| 教育| 资兴市| 同江市| 岑溪市| 额尔古纳市| 呈贡县| 延寿县| 丰宁| 阿图什市| 贵溪市| 长春市| 平阳县| 施秉县| 乐都县| 昭平县| 江陵县| 彭山县| 青铜峡市| 蓝山县| 邯郸县| 辰溪县| 河北区| 清新县| 潮州市| 镇坪县| 沁水县| 夏津县| 潢川县|