Kotlin Basic Tutorial-Package

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.