Packages
A source file typically starts with a definition package
Package Com.doctorq.packages Fun
Main (args:array<string>) {
println ("Hello world!")
}
Class foo{}
Note that this place is not directly related to the directory where the package name and source files are located, and the compiled file will install the defined package name to generate the appropriate directory
Default imported Package kotlin.* kotlin.annotation.* kotlin.collections.* kotlin.comparisons.* (since 1.1) kotlin.io.* kotlin.ranges.* kotlin.sequences.* kotlin.text.* JVM
java.lang.* kotlin.jvm.* JS
kotlin.js.* Importing Packages
If we have a class that is located under Com.doctorq
Import All
Import com.doctorq.*
Accurate Import
Import Com.doctorq.Bar
Change the name after import, similar to how Python was imported
Import Docm.doctorq.Bar as DBar
Import is used not only to import classes, but also to import other, such as: Advanced functions and properties enumeration of functions and properties in Object objects
There is no import static in Kotlin, and import is used for static resource visibility
If you use private to define a target, the target can only be accessed in the definition file.