# Repository Overview

Welcome to this repository. This codebase appears to be a compact set of Java 11 feature examples, organized as small, focused modules that each demonstrate one language or standard-library capability. Rather than a single application, it reads like a learning and reference project for exploring modern Java syntax and APIs. The examples are intentionally direct, which makes the repository a good place to learn by reading the code in small pieces.

If you are new here, think of each package as a self-contained demo. Some examples show language features such as `var`, try-with-resources, private interface methods, and single-file execution. Others focus on standard library areas like collections, strings, time, files, processes, and the HTTP client.

## Overview

This repository appears to be an instructional Java 11 examples project. Each top-level module focuses on one topic and keeps the implementation small enough to read in a few minutes. The code is centered around runnable `Example` classes and a few supporting types, so the best way to understand it is to open a module, run its entry point, and compare the behavior with the source.

The modules are independent of each other. There is no sign of a larger application framework, service layer, or persistence stack, so the project seems designed for experimentation, documentation, and hands-on learning rather than production deployment.

## Technology Stack

The repository appears to use:

- **Java 11** as the primary language and runtime target
- **JDK standard library APIs** for collections, files, strings, time, process inspection, try-with-resources, interfaces, and HTTP
- **Gson** for JSON serialization in the HTTP example
- **Mermaid** for lightweight architecture diagrams in the documentation

No well-known application frameworks were detected from the imported code. That suggests the repository is intentionally dependency-light and focused on core language features.

## Architecture

At a high level, the repository is organized as a set of topic-based examples under `io.github.biezhi.java11`. Each topic stands alone and typically contains one runnable example class. Supporting classes are only added when a demo needs them, such as the `Foo` payload used by the HTTP example or the generic handler used in the collections example.

```mermaid
flowchart TD
Repository["Java 11 Examples Repository"] --> Collections["collections"]
Repository --> Files["files"]
Repository --> Http["http"]
Repository --> Interfaces["interfaces"]
Repository --> Processor["processor"]
Repository --> Singlefile["singlefile"]
Repository --> StringMod["string"]
Repository --> TimeMod["time"]
Repository --> TryWithResources["trywithresources"]
Repository --> VarMod["var"]

Http --> Foo["Foo payload class"]
Collections --> MyHandler["MyHandler generic helper"]
```

The structure is intentionally shallow: each module is mostly a direct entry point into one language feature or API. That keeps the examples easy to run independently and reduces cross-module coupling.

## Module Guide

### `collections`
This module appears to demonstrate modern collection factory methods and the diamond operator. The key classes are `Example`, which shows immutable `List`, `Map`, and `Set` creation, and `DiamondOperatorExample`, which demonstrates anonymous generic classes with diamond inference. If you are exploring how Java 11 handles concise collection setup or generic anonymous classes, this is a good place to start.

### `files`
This module appears to show the `Files` API in its simplest form. Its `Example` class writes a text file, reads it back, compares the result, and deletes the file. It is a useful reference for the basic write-read-delete workflow when working with text files in Java.

### `http`
This module appears to be the most feature-rich example in the repository. Its `Example` class demonstrates synchronous and asynchronous requests, JSON posting, file upload and download, proxy configuration, authentication, HTTP/2, and batch fan-out. The supporting `Foo` class is a small request payload used for JSON serialization.

### `interfaces`
This module appears to demonstrate private interface methods alongside default methods and one abstract method. The `Example` interface shows how shared helper logic can live inside an interface without becoming part of the public contract. It is a compact example of interface design in modern Java.

### `processor`
This module appears to show process inspection through `ProcessHandle`. Its `Example` class prints the current JVM process ID, making it a minimal example of the Java process API.

### `singlefile`
This module appears to demonstrate Java's single-file source execution workflow. The `HelloWorld` class prints a greeting and is meant to be run directly from source, which makes it a tiny example of JEP 330-style execution.

### `string`
This module appears to focus on Java 11 string utilities such as `repeat`, `lines`, and the `strip` family of methods. Its `Example` class is a runnable demo that prints outputs for each feature.

### `time`
This module appears to cover Java time API usage. The indexed documentation shows a single `Example` class that serves as the package entry point, but the implementation details are not fully visible in the available index.

### `trywithresources`
This module appears to demonstrate the Java 9+ style of try-with-resources, where an effectively final variable can be reused in the resource header. Its `Example` class reads and prints `./README.md` while letting the runtime close the reader automatically.

### `var`
This module appears to demonstrate local variable type inference with `var`. The `Example` class shows `var` in local declarations, enhanced for-loops, streams, file operations, and try-with-resources, making it a good reference for where the feature is allowed and how it reads in practice.

## Getting Started

If you are new to the repository, start with the most general examples first:

1. **`singlefile/HelloWorld`** — quickest entry point; confirms the repository's single-file execution style.
2. **`var/Example`** — shows the modern `var` syntax in several everyday positions.
3. **`collections/Example`** — introduces immutable collection factory methods.
4. **`string/Example`** — demonstrates the Java 11 string API enhancements.
5. **`trywithresources/Example`** — shows the updated resource declaration style.
6. **`files/Example`** — introduces basic file round-trip behavior.
7. **`interfaces/Example`** — explains private interface methods and default-method reuse.
8. **`processor/Example`** — short example of process ID inspection.
9. **`http/Example`** — best read after the basics, since it combines several APIs and external endpoints.
10. **`time/Example`** — review after the other modules, especially if you want to compare Java time usage with the rest of the examples.

A practical reading order is to begin with the small syntax-focused demos, then move to the I/O and networking examples. The most useful entry points are usually the `main` methods in each `Example` class, because the repository is structured around runnable snippets rather than library APIs.

If you want to understand how a feature works, read the module page first, then inspect the referenced source file. The code is intentionally compact, so the documentation and the implementation should line up closely.
