- Learn Kotlin Programming(Second Edition)
- Stephen Samuel Stefan Bocutiu
- 130字
- 2021-06-24 14:13:26
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.
推薦閱讀
- Vue 3移動Web開發與性能調優實戰
- ASP.NET Web API:Build RESTful web applications and services on the .NET framework
- Spring Boot開發與測試實戰
- Hyper-V 2016 Best Practices
- Vue.js快跑:構建觸手可及的高性能Web應用
- C# 8.0核心技術指南(原書第8版)
- 青少年信息學競賽
- Python入門很輕松(微課超值版)
- Arduino可穿戴設備開發
- App Inventor少兒趣味編程動手做
- Android應用開發實戰(第2版)
- After Effects CC案例設計與經典插件(視頻教學版)
- Web開發新體驗
- 區塊鏈:技術與場景
- IBM DB2 9.7 Advanced Application Developer Cookbook