본문

170614(수) - Kotlin docs (Packages)

Kotlin docs


Packages


Packages

package foo.bar


fun baz() {}


class Goo {}


// ...


Default Imports

- every kotlin file

    • kotlin.*
    • kotlin.annotation.*
    • kotlin.collections.*
    • kotlin.comparisons.* (since 1.1)
    • kotlin.io.*
    • kotlin.ranges.*
    • kotlin.sequences.*
    • kotlin.text.*


- Additional packages are depending on target platform.

- JVM

java.lang.*

kotlin.jvm.*


- JS

kotlin.js.*




Imports

import foo.Bar            // Bar is now accessible without qualification


import foo.*               // everything in 'foo' accessible


import foo.Bar

import bar.Bar as bBar  // bBar stand for 'bar.Bar'


- import는 importing class 말고도 여러가지 선언 가능

- top-level functions and properties

- functions and properties declared in object declarations

- enum constants



- Java의 import static은 사용 불가능




Visibility of Top-level Declarations

top-level declaration이 private이면 선언된 파일도private이다.

공유

댓글