- Hands-On Design Patterns with Kotlin
- Alexey Soshin
- 101字
- 2021-06-25 20:49:23
Packages
It wouldn't be convenient to have all your classes and functions in the same folder or under the same namespace. That's the reason Kotlin, similar to many other languages, uses the notion of a package.
Like Java, Kotlin uses packages:
package me.soshin.controllers
If you're mixing Java and Kotlin, Kotlin files should follow Java package rules.
In purely Kotlin projects, common package prefixes can be omitted from the folder structure. For example, if all your projects are under the me.soshin package, place your controllers in the /controllers folder and not in the /me/soshin/controllers folder like Java does.