> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kotlin Import Declaration

An import declaration in Kotlin is a file-level directive used to bring declarations from other packages or classifiers into the current namespace, allowing them to be referenced by their simple names rather than their fully qualified names (FQN).

Import directives must be declared after the `package` directive (if one exists) and before any top-level declarations (classes, functions, properties, or objects).

## Syntax and Types of Imports

Kotlin supports three primary forms of import declarations:

**1. Single-Name Import**
Brings a specific, single declaration into the current file scope.

```kotlin theme={"dark"}
package org.example.app

import org.example.network.HttpClient

class Service {
    val client = HttpClient() 
}
```

**2. On-Demand (Wildcard) Import**
Brings all accessible declarations from a specified package or classifier into the current scope. The compiler resolves the specific declarations at compile time.

```kotlin theme={"dark"}
import java.io.*

fun read(file: File) { 
    // ...
}
```

**3. Aliased Import**
Introduces a local alias for an imported declaration. This is strictly a file-level rename and is primarily used to resolve namespace collisions between declarations with identical simple names from different packages.

```kotlin theme={"dark"}
import java.util.Date as UtilDate
import java.sql.Date as SqlDate

val utilDate = UtilDate()
val sqlDate = SqlDate(System.currentTimeMillis())
```

## Importable Entities

Unlike Java, which requires a distinct `import static` directive for static members, Kotlin uses a unified `import` syntax for all entities. You can import:

* Top-level classes and interfaces.
* Top-level functions and properties.
* Functions and properties declared inside `object` or `companion object` declarations.
* Enum constants.
* Java static methods and fields.

```kotlin theme={"dark"}
// Importing a top-level function
import kotlin.math.max

// Importing an enum constant directly
import kotlin.annotation.AnnotationTarget.CLASS

// Importing a companion object member
import kotlin.Int.MAX_VALUE

// Importing a Java static method
import java.time.LocalDate.now
```

## Default Imports

The Kotlin compiler implicitly injects a standard set of import directives into every Kotlin file. This eliminates the need to manually import core language constructs.

The universal default imports include:

* `kotlin.*`
* `kotlin.annotation.*`
* `kotlin.collections.*`
* `kotlin.comparisons.*`
* `kotlin.io.*`
* `kotlin.ranges.*`
* `kotlin.sequences.*`
* `kotlin.text.*`

Additional default imports are applied based on the target platform. For the JVM, the compiler implicitly imports:

* `java.lang.*`
* `kotlin.jvm.*`

## Scope and Resolution Mechanics

* **File-Scoped:** The scope of an import declaration is strictly limited to the file in which it is defined. It does not leak into other files within the same package.
* **Visibility Agnostic:** Import declarations do not bypass visibility modifiers (`private`, `internal`, etc.). You can only import declarations that are visible to the current file based on Kotlin's standard visibility rules.
* **Resolution Priority:** During scope resolution, explicit (single-name) imports have a higher priority than declarations defined in the current package. Conversely, declarations in the current package take precedence over entities brought in via on-demand (star) imports. If a naming collision occurs between an explicit import and a declaration in the current package, the explicit import shadows the package declaration, and a fully qualified name must be used to access the package-level entity.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Kotlin Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
