K
K
keddad2020-04-14 22:31:47
Kotlin
keddad, 2020-04-14 22:31:47

Why does Koltlin import all classes from a local package?

I have a Kotlin project with this structure:

.
└── org
    └── gradle
        └── sample
            ├── JoinUtils.kt
            ├── LinkedList.kt
            ├── Main.kt
            ├── MessageUtils.kt
            ├── SplitUtils.kt
            └── StringUtils.kt

Main.kt looks like this:
package org.gradle.sample

fun main() {
    val tokens = StringUtils.split(MessageUtils.getMessage())
    println(StringUtils.join(tokens))
}


Where StringUtils, MessageUtils are classes from this directory that have the same package. Why are they available to me? The code compiles and works. I don't import them, and the documentation doesn't include them in the default imports. Shouldn't I be importing them explicitly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
illuzor, 2020-04-14
@keddad

Classes from the same package do not need to be imported.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question