# Repository Overview

Welcome to this repository. This appears to be a compact Java 11 learning and reference project built around small, focused examples rather than a single production application. Each package demonstrates one language or standard-library feature in isolation, which makes the code easy to explore and reuse as a teaching aid. If you are new here, think of the repository as a tour of modern Java 11 capabilities through runnable snippets.

The codebase is intentionally lightweight: there is no large framework layer, and the examples rely mostly on the Java standard library, with Gson appearing in the HTTP module. That means the best way to understand the project is to read the example classes package by package and run them individually. The documentation below is organized to help you find the entry points quickly and understand how the pieces relate.

## Overview

This repository appears to collect self-contained examples for Java 11 features such as immutable collections, the `Files` API, the HTTP client, private interface methods, the Process API, single-file execution, updated `String` methods, time conversions, try-with-resources, and local variable inference with `var`. Most modules contain a single executable `Example` class or a similarly small demo class, and the intent seems educational: show the syntax, the API shape, and the runtime behavior in a way that can be read top to bottom.

The code does not appear to implement a cohesive business system or layered application. Instead, each package is a small island of behavior, usually with console output as the visible effect. That makes the repository useful as a set of reference snippets for engineers learning Java 11 or looking for a quick reminder of a specific API.

## Technology Stack

This repository appears to use plain Java 11 with the standard library as its primary platform. Based on the available source, the detected technologies are:

- Java 11 language features such as `var`, private interface methods, and single-file launch support
- Standard Java APIs including `java.nio.file`, `java.net.http`, `java.time`, `java.util.concurrent`, `java.io`, and `java.lang.ProcessHandle`
- Gson in the HTTP example for JSON serialization

No well-known application framework was detected from import analysis. There is also no sign of a broader web, persistence, or dependency-injection stack in the indexed files, which reinforces the impression that this is a feature showcase rather than an application scaffold.

## Architecture

At a high level, the repository is organized as a set of independent feature modules under `io.github.biezhi.java11`. The modules do not appear to depend on each other in meaningful ways; they mostly depend on the JDK and, in one case, Gson. The architecture is therefore closer to a catalog of runnable samples than a layered service architecture.

```mermaid
flowchart TD
Root["Repository Overview"] --> CollectionsModule["collections"]
Root --> FilesModule["files"]
Root --> HttpModule["http"]
Root --> InterfacesModule["interfaces"]
Root --> ProcessorModule["processor"]
Root --> SinglefileModule["singlefile"]
Root --> StringModule["string"]
Root --> TimeModule["time"]
Root --> TryWithResourcesModule["trywithresources"]
Root --> VarModule["var"]
CollectionsModule --> CollectionsExample["Example and DiamondOperatorExample"]
HttpModule --> HttpExample["Example and Foo"]
InterfacesModule --> InterfacesExample["Example interface"]
ProcessorModule --> ProcessorExample["Example"]
SinglefileModule --> SinglefileExample["HelloWorld"]
StringModule --> StringExample["Example"]
TimeModule --> TimeExample["Example"]
TryWithResourcesModule --> TryExample["Example"]
VarModule --> VarExample["Example"]
```

In practical terms, each package is a standalone demo. The main dependencies are from each example class to the Java API it showcases, not from one feature area to another.

## Module Guide

### collections

This module appears to demonstrate immutable collection factories and the diamond operator in anonymous inner classes. The main classes are [`Example`](src/main/java/io/github/biezhi/java11/collections/Example.java) and [`DiamondOperatorExample`](src/main/java/io/github/biezhi/java11/collections/DiamondOperatorExample.java). `Example` shows `List.of`, `Map.of`, `Map.ofEntries`, `Map.entry`, and `Set.of`, while `DiamondOperatorExample` centers on the generic nested type `MyHandler<T>` and how type inference behaves with anonymous subclasses.

### files

This module appears to be a small file I/O walkthrough. The primary class is [`Example`](src/main/java/io/github/biezhi/java11/files/Example.java), which writes a string to `hello.txt`, reads it back, compares the values, and deletes the file. It is a concise demonstration of `Files.writeString`, `Files.readString`, and `Files.delete`.

### http

This module appears to showcase the Java 11 HTTP client. The main class is [`Example`](src/main/java/io/github/biezhi/java11/http/Example.java), with [`Foo`](src/main/java/io/github/biezhi/java11/http/Foo.java) acting as a tiny DTO for JSON serialization. The examples cover synchronous and asynchronous requests, file downloads, file uploads, proxies, basic authentication, HTTP/2, and concurrent request fan-out.

### interfaces

This module appears to focus on modern interface design, especially private and default methods. [`Example`](src/main/java/io/github/biezhi/java11/interfaces/Example.java) is actually an interface, not a class. It combines an abstract method, two default methods that share a private helper, and a private static method, illustrating how Java 9+ lets interfaces encapsulate implementation details more cleanly.

### processor

This module appears to demonstrate the Process API. The single class, [`Example`](src/main/java/io/github/biezhi/java11/processor/Example.java), obtains the current `ProcessHandle` and prints the PID of the running JVM. It is a minimal example of process introspection.

### singlefile

This module appears to demonstrate Java 11 single-file execution. [`HelloWorld`](src/main/java/io/github/biezhi/java11/singlefile/HelloWorld.java) is a tiny runnable class that prints a greeting. The package is useful for understanding the simplest possible source-file launch workflow.

### string

This module appears to showcase Java 11 `String` APIs. [`Example`](src/main/java/io/github/biezhi/java11/string/Example.java) contains several demo methods for `lines`, `strip`, `stripLeading`, `stripTrailing`, and `isBlank`, plus a small console-formatting helper built with `String.repeat`.

### time

This module appears to demonstrate time conversion between `Duration` and `TimeUnit`. [`Example`](src/main/java/io/github/biezhi/java11/time/Example.java) prints a few examples that show how whole-unit conversion works when translating durations into days or minutes.

### trywithresources

This module appears to focus on try-with-resources syntax. [`Example`](src/main/java/io/github/biezhi/java11/trywithresources/Example.java) opens `README.md` with a `BufferedReader`, reads it line by line, and relies on try-with-resources to close the reader automatically.

### var

This module appears to be a grab bag of `var` examples. [`Example`](src/main/java/io/github/biezhi/java11/var/Example.java) demonstrates local type inference with collections, streams, file paths, byte arrays, enhanced `for`, and a try-with-resources declaration.

## Getting Started

If you are new to the repository, a good reading order is to start with the package summaries above and then open the runnable examples one by one. A practical path would be:

1. Read [`var/Example`](src/main/java/io/github/biezhi/java11/var/Example.java) to get a feel for local type inference and the general demo style used throughout the project.
2. Read [`string/Example`](src/main/java/io/github/biezhi/java11/string/Example.java) and [`collections/Example`](src/main/java/io/github/biezhi/java11/collections/Example.java) to see common Java 11 language and library conveniences in action.
3. Read [`files/Example`](src/main/java/io/github/biezhi/java11/files/Example.java) and [`trywithresources/Example`](src/main/java/io/github/biezhi/java11/trywithresources/Example.java) to understand the repository’s file-handling examples.
4. Read [`http/Example`](src/main/java/io/github/biezhi/java11/http/Example.java) and [`http/Foo`](src/main/java/io/github/biezhi/java11/http/Foo.java) if you want the most feature-rich example in the repository.
5. Finish with [`interfaces/Example`](src/main/java/io/github/biezhi/java11/interfaces/Example.java), [`processor/Example`](src/main/java/io/github/biezhi/java11/processor/Example.java), [`time/Example`](src/main/java/io/github/biezhi/java11/time/Example.java), and [`singlefile/HelloWorld`](src/main/java/io/github/biezhi/java11/singlefile/HelloWorld.java) for the smaller feature-specific samples.

For most modules, the `main` method is the entry point to look for first. If you are trying to understand the behavior of a specific Java 11 feature, the source files named `Example.java` are the best starting point, and the surrounding package documentation can help you compare related samples.

## Module Cross-References

- The `collections` package contains both a general collection-factory demo and a separate diamond-operator example.
- The `http` package is the only one that appears to use a third-party library, Gson, and it also contains the `Foo` data holder used by the JSON POST example.
- The `interfaces` package is notable because its top-level type is an interface rather than a class.
- The `trywithresources` and `files` packages both deal with file I/O, but they demonstrate different aspects: resource cleanup versus read/write/delete flow.
- The `var` package touches several standard APIs at once, so it is a useful orientation point before reading the more specialized examples.

## Practical Notes

- These samples are primarily instructional. They often print to standard output instead of returning values, so they are best treated as runnable documentation.
- Several examples use concrete file names or network endpoints. When running them locally, check the assumptions carefully before executing the sample.
- The repository appears small enough that you can understand it package by package without needing to trace deep dependency chains.
- If you are extending the code, preserve the “one concept per example” style so the repository stays approachable for future readers.
