# Business Logic — Example.main() [9 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `io.github.biezhi.java11.string.Example` |
| Layer | Utility / Demo |
| Module | `string` (Package: `io.github.biezhi.java11.string`) |

## 1. Role

### Example.main()

`Example.main()` serves as the program entry point (Java standard `public static void main`) for the Java 11 String API demo application. It demonstrates one of the new String methods introduced in Java 11 — specifically `String.lines()`, which produces a `Stream<String>` of the lines contained in a string, automatically handling line separators. The method delegates to `lines()`, which in turn calls `writeHeader()` to display a formatted header and prints the result of `str.lines().collect(Collectors.toList())` to standard output, showing each line of a multi-line string as a list. Design-wise, it functions as a demo runner and follows the same pattern used by all other demonstration methods in the class (`demonstrateStringLines()`, `demonstrateStringStrip()`, etc.). Its role in the larger system is purely educational — it is part of a sample repository (biezhi/java11-string) showcasing Java 11 language features, not an enterprise application component.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["main(String[] args)"])
    STEP(["Call lines()"])
    END_NODE(["Return / Exit"])

    START --> STEP --> END_NODE
```

**Block-level description:**
- `main` receives the CLI argument array `args` but ignores it entirely.
- It calls `lines()`, which outputs a formatted header and prints the lines of a hardcoded multi-line string.
- Returns `void`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `args` | `String[]` | Command-line arguments passed to the JVM. Unused in this method — the demo has no external input and all strings are hardcoded. |

No instance fields or external state are read by this method.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `Example.lines` | Example | - | Calls `lines()` in `Example` to print multi-line string via `String.lines()` |

No database, entity, or service component operations exist in this method. It performs only console output.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | JVM Entry Point | `jvm` -> `Example.main(String[])` | `lines() [R] stdout` |

No callers found within the project. `main()` is invoked only by the JVM at startup.

## 6. Per-Branch Detail Blocks

**Block 1** — [ENTRY POINT] `(public static void main(String[] args))` `(L104)`

> Entry point that delegates to the `lines()` demo method. All other demonstration methods are commented out.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `lines()` | // Calls the `lines()` demo method |

No conditional branches, loops, or nested blocks exist. The commented-out calls show other demo methods (`demonstrateStringLines()`, `demonstrateStringStrip()`, `demonstrateStringStripLeading()`, `demonstrateStringStripTrailing()`, `demonstrateStringIsBlank()`) but none are active.

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `String.lines()` | Java 11 API | Returns a `Stream<String>` splitting the string by line terminators (
, \r, \r
) |
| `String.strip()` | Java 11 API | Removes leading and trailing Unicode whitespace |
| `String.stripLeading()` | Java 11 API | Removes leading Unicode whitespace only |
| `String.stripTrailing()` | Java 11 API | Removes trailing Unicode whitespace only |
| `String.isBlank()` | Java 11 API | Returns true if the string is empty or contains only whitespace characters |
| `String.repeat(int)` | Java 11 API | Returns a string repeated the specified number of times |
| `Collectors.toList()` | Java API | Collects a stream into a mutable `List` |
| JVM | Acronym | Java Virtual Machine — entry point for running Java applications |
