The Java HTTP Client
Since Java 11 the platform includes a modern HTTP client with synchronous and asynchronous requests and HTTP/2 support.
Features from Java 8 onwards.
23 notes tagged
Since Java 11 the platform includes a modern HTTP client with synchronous and asynchronous requests and HTTP/2 support.
What changed in each release since Java 8, which old habits it replaces, and what to reach for in new code today.
A sealed type names exactly which types may extend it, which lets the compiler check that a pattern switch covers every case.
Modules add a boundary above packages: a module declares what it needs and what it exposes, and everything else stays private.
A Future is a placeholder for a result that is not ready yet. CompletableFuture adds composition, so results can be chained without blocking.
An executor separates submitting work from running it, so threads are reused instead of created per task.
Path names a location and Files performs the operations. Together they replaced the older File class for almost every purpose.
DateTimeFormatter converts between text and date time values, and ZoneId handles the region rules that make time zones difficult.
Instant marks a point on the timeline; Duration measures time based amounts and Period measures date based ones.
The modern date and time API is immutable, thread safe and clearly named, and it replaced the older Date and Calendar classes entirely.
A parallel stream splits the work across threads. It helps less often than people expect, and it breaks silently when the rules are ignored.
Collectors turn a stream into a collection, a map or a summary, and grouping is where they become genuinely powerful.