> ## 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.

# Java Single-Type-Import Declaration

A single-type-import declaration makes a specific type (class, interface, enum, annotation, or record) from another package available by its simple name within the current compilation unit. It establishes a direct mapping between the fully qualified name (FQN) of the type and its simple name, instructing the compiler to resolve the simple name to the FQN during the compilation phase.

```java theme={"dark"}
import PackageName.SimpleTypeName;
```

**Structural Placement**
The declaration must appear after the `package` declaration (if one exists) and before any top-level type declarations within the `.java` source file.

**Resolution and Accessibility**
The compiler strictly evaluates the FQN provided in the declaration. If the specified type does not exist, or if it lacks the appropriate access modifiers (e.g., attempting to import a package-private type from a different package), the compiler throws an error.

**Naming Conflicts and Shadowing**

* **Import Collisions:** It is a compile-time error to declare multiple single-type-imports that resolve to the same simple name but different FQNs.

```java theme={"dark"}
import java.util.Date;
import java.sql.Date; // Compile-time error: Date is already defined in a single-type import
```

* **Precedence over Import-on-Demand:** A single-type-import declaration shadows any type with the identical simple name that is imported via an import-on-demand declaration (e.g., `import java.util.*;`).
* **Conflict with Local Types:** It is a compile-time error if a single-type-import declaration has the same simple name as a top-level type declared within the same compilation unit. The local type does not shadow the import; instead, the compiler rejects the duplicate name definition.

**Redundancy**
A single-type-import declaration is considered redundant, though syntactically legal, if it targets:

1. A type within the `java.lang` package, which the compiler imports implicitly.
2. A type within the same package as the current compilation unit.
3. A type that has already been declared in a previous single-type-import within the same file.

**Nested Types**
A single-type-import can be used to import a nested type by referencing its enclosing class in the FQN. However, importing an enclosing class does *not* implicitly import its nested types; they must be referenced using their qualified names relative to the imported enclosing class, or imported explicitly via their own single-type-import declarations.

```java theme={"dark"}
// Importing a nested type directly
import java.util.Map.Entry; 
```

<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 Java 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>
