# Getting Started

## What This Project Does

This repository is a small set of Java 11 examples that demonstrate language and library features introduced after Java 8. The code is organized as focused snippets you can run individually to learn by example, rather than as a single application.

If you are new to the codebase, think of it as a cookbook: each package shows one Java 11 capability with a self-contained `Example` class or helper.

## Recommended Reading Order

1. **Start with the repository overview**: [`README.md`](../README.md) for the high-level list of topics.
2. **Read the Java 11 feature samples in this order**:
   - [`src/main/java/io/github/biezhi/java11/var/Example.java`](../../src/main/java/io/github/biezhi/java11/var/Example.java)
   - [`src/main/java/io/github/biezhi/java11/string/Example.java`](../../src/main/java/io/github/biezhi/java11/string/Example.java)
   - [`src/main/java/io/github/biezhi/java11/collections/Example.java`](../../src/main/java/io/github/biezhi/java11/collections/Example.java)
   - [`src/main/java/io/github/biezhi/java11/interfaces/Example.java`](../../src/main/java/io/github/biezhi/java11/interfaces/Example.java)
   - [`src/main/java/io/github/biezhi/java11/files/Example.java`](../../src/main/java/io/github/biezhi/java11/files/Example.java)
   - [`src/main/java/io/github/biezhi/java11/time/Example.java`](../../src/main/java/io/github/biezhi/java11/time/Example.java)
   - [`src/main/java/io/github/biezhi/java11/trywithresources/Example.java`](../../src/main/java/io/github/biezhi/java11/trywithresources/Example.java)
   - [`src/main/java/io/github/biezhi/java11/processor/Example.java`](../../src/main/java/io/github/biezhi/java11/processor/Example.java)
   - [`src/main/java/io/github/biezhi/java11/http/Example.java`](../../src/main/java/io/github/biezhi/java11/http/Example.java)
   - [`src/main/java/io/github/biezhi/java11/singlefile/HelloWorld.java`](../../src/main/java/io/github/biezhi/java11/singlefile/HelloWorld.java)
3. **Use the Maven build file last**: [`pom.xml`](../pom.xml) to confirm dependencies and Java version settings.

## Key Entry Points

There are no highly connected classes in this repo, so the best entry points are the per-feature examples:

- [`io.github.biezhi.java11.var.Example`](../../src/main/java/io/github/biezhi/java11/var/Example.java) — local variable type inference (`var`) and simple file/stream examples.
- [`io.github.biezhi.java11.string.Example`](../../src/main/java/io/github/biezhi/java11/string/Example.java) — Java 11 `String` helpers such as `lines()`, `strip()`, and `isBlank()`.
- [`io.github.biezhi.java11.collections.Example`](../../src/main/java/io/github/biezhi/java11/collections/Example.java) — immutable collection factories like `List.of`, `Map.of`, and `Set.of`.
- [`io.github.biezhi.java11.interfaces.Example`](../../src/main/java/io/github/biezhi/java11/interfaces/Example.java) — interface private methods and default method reuse.
- [`io.github.biezhi.java11.http.Example`](../../src/main/java/io/github/biezhi/java11/http/Example.java) — the most complete sample, covering sync/async HTTP, JSON, file upload/download, proxying, and HTTP/2.

## Project Structure

- `src/main/java/io/github/biezhi/java11/var/` — `var` examples and basic NIO/file usage.
- `src/main/java/io/github/biezhi/java11/string/` — string-processing demos.
- `src/main/java/io/github/biezhi/java11/collections/` — collection factory APIs and immutable data structures.
- `src/main/java/io/github/biezhi/java11/interfaces/` — interface defaults and private helper methods.
- `src/main/java/io/github/biezhi/java11/files/` — `Files.readString` / `Files.writeString` / delete examples.
- `src/main/java/io/github/biezhi/java11/time/` — date/time conversion examples.
- `src/main/java/io/github/biezhi/java11/trywithresources/` — try-with-resources syntax.
- `src/main/java/io/github/biezhi/java11/processor/` — process API usage.
- `src/main/java/io/github/biezhi/java11/http/` — HTTP client examples plus the small `Foo` DTO.
- `src/main/java/io/github/biezhi/java11/singlefile/` — single-file execution example.

## Configuration

- [`pom.xml`](../pom.xml) defines the Maven build, Java 11 release level, and the only third-party dependency (`gson`).
- The Surefire plugin adds `--add-modules=jdk.incubator.httpclient`, which is relevant if you run tests or examples that rely on incubating HTTP client modules in older JDK setups.
- [`src/jenkinsfile`](../src/jenkinsfile) is a minimal CI pipeline that only installs Maven, so it is mostly a placeholder rather than a full build workflow.

## Common Patterns

- **One topic per package**: each folder focuses on a single Java 11 feature.
- **Self-contained examples**: most classes have a `main` method so you can run them directly.
- **Print-to-console demos**: examples usually show behavior by printing output instead of asserting through a test harness.
- **Minimal shared abstraction**: there is little cross-package coupling, so reading a package in isolation is usually enough.
- **Use of modern Java APIs**: expect `var`, `List.of`, `String.lines()`, `Files.readString`, and `HttpClient` throughout the code.

## Where to Go Next

After this guide, read the package that matches what you want to learn first, then open `pom.xml` to understand the runtime assumptions. If you want the most complete feature tour, start with the HTTP example and then compare it with the simpler string and collection samples.
