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

The `*` token in Kotlin functions as a binary arithmetic operator for multiplication, a unary prefix spread operator for array unpacking, a star projection token within the generic type system, and a wildcard character in import directives.

## Binary Arithmetic Operator (Multiplication)

As a binary operator, `*` performs arithmetic multiplication. Kotlin resolves this via operator overloading, mapping the `*` symbol to the `times()` member or extension function.

```kotlin theme={"dark"}
// Syntactic representation
val result = a * b

// Compiler translation
val result = a.times(b)
```

To enable the `*` operator for custom classes, the type must declare a function named `times` accompanied by the `operator` modifier. The operand type and return type are strictly defined by the function signature.

```kotlin theme={"dark"}
class Matrix {
    operator fun times(scalar: Int): Matrix {
        return Matrix()
    }
}
```

## Unary Prefix Spread Operator

When positioned as a prefix immediately preceding an array identifier, `*` acts as the spread operator. It unpacks the elements of an array, allowing them to be passed as discrete arguments to a function parameter declared with the `vararg` modifier.

```kotlin theme={"dark"}
fun processElements(vararg elements: String) {
    // Function body
}

val stringArray = arrayOf("A", "B", "C")

// Applying the spread operator
processElements(*stringArray)
```

**Mechanical Characteristics:**

* **Type Restriction:** The spread operator is strictly compatible with arrays (e.g., `Array<T>`, `IntArray`, `DoubleArray`). It cannot be applied directly to a `Collection<T>` (which requires conversion via `.toTypedArray()`) or a pure `Iterable<T>` (which requires conversion via `.toList().toTypedArray()`).
* **Memory Allocation and Mutation:** Invoking the spread operator creates a shallow copy of the array elements. For object types, a `vararg` parameter compiles to `Array<out T>`, where the `out` variance inherently prevents element mutation at compile time. However, for primitive arrays (e.g., `IntArray`), element mutation is permitted. In these cases, the shallow copy ensures that any modifications to the array's elements within the function do not affect the original array.
* **Argument Composition:** The operator can be interleaved with standard, comma-separated arguments within the same function invocation.

```kotlin theme={"dark"}
processElements("Prefix", *stringArray, "Suffix")
```

## Star Projection (Generics)

While structurally a type projection rather than an expression-level operator, `*` is utilized within angle brackets to denote an unknown type argument in parameterized types.

```kotlin theme={"dark"}
val heterogeneousList: List<*> = listOf(1, "Two", 3.0)
```

Mechanically, `*` provides a safe approximation of a generic type based on its variance declaration and upper bounds:

* For a covariant type parameter (`out T : TUpper`), `*` projects to `out TUpper`, allowing safe reads of the upper bound. If no explicit upper bound is declared, it defaults to `out Any?`.
* For a contravariant type parameter (`in T`), `*` projects to `in Nothing`, preventing unsafe writes to the generic instance.
* For an invariant type parameter (`T : TUpper`), `*` projects to `out TUpper` for reading and `in Nothing` for writing.

## Wildcard Import

In file headers, the `*` token acts as a wildcard within `import` directives. It instructs the compiler to import all accessible top-level declarations (classes, interfaces, functions, and properties) from a specified package or classifier, eliminating the need to import each member individually.

```kotlin theme={"dark"}
// Imports all members of java.util
import java.util.*

// Imports all nested declarations of a specific class or object
import org.example.Constants.*
```

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