Nearby lessons
116 of 125Java 11 Features
- Why Java 11 is an important LTS version
- The new String methods: isBlank, strip, repeat, lines
- var in lambda parameters
- Running a single Java file directly
- The new HttpClient
Java 11 Features is a core concept of the Java language. This lesson explains Java 11 — A Long-Term Support (LTS) Version, New String Methods and strip() vs trim() — Small but Important with complete, runnable code examples, clear step-by-step explanations, and common mistakes to avoid with exam-style MCQs at the end.
Java 11 — A Long-Term Support (LTS) Version
Java 11 (September 2018) is a Long-Term Support (LTS) version — it gets updates and security patches for years. Companies trust Java 11 (along with 8, 17 and 21). It also cleaned up the platform by removing old, unused things like the Java EE modules and the JavaFX bundling.
New String Methods
Java 11 gave String several handy methods that every developer uses daily:
strip() vs trim() — Small but Important
| Point | trim() (old) | strip() (Java 11) |
|---|---|---|
| Introduced in | Java 1.0 | Java 11 |
| Removes | Spaces with code <= 32 (ASCII spaces) | All Unicode spaces (including tab, newline) |
| Standard | Old, ASCII-based | Modern, Unicode-aware |
| Best choice | Legacy code | New code |
var in Lambda Parameters
Java 11 allows var inside lambda parameters — useful when you want to add annotations to the parameter:
Run a Single Java File Directly
Before Java 11, running a program needed two steps: javac Hello.java then java Hello. Java 11 added a shortcut — the single-file source-code launch. It compiles in memory and runs:
This works only for a single file program (no external dependencies). Great for quick tests and small scripts — and it made learning Java simpler.
The New HttpClient
Java 11 made the HttpClient standard (it was an incubator in Java 9). It lets Java programs call web APIs cleanly — a huge topic for modern apps:
Other Java 11 Changes
- Removed old Java EE modules (CORBA, JAXB, JAX-WS) — the platform became lighter.
- Removed finalize() from use (deprecated; see Garbage Collection chapter).
- Nest-based access control — a technical speed-up for nested classes.
- ZGC and Epsilon — experimental new garbage collectors (ZGC became stable in Java 15).
- TLS 1.3 support — modern secure connections.
Java 11 is still widely used in industry today. Companies that moved from Java 8 usually went to 11 first, then to 17 and 21.
- Java 11 is an LTS version — trusted by companies for long-term support.
- New String methods: isBlank(), strip(), repeat(), lines().
- var is allowed in lambda parameters (mainly for annotations).
- java Hello.java compiles and runs a single file in one command.
- HttpClient is now standard for calling web APIs.
- Old Java EE modules were removed to make the platform lighter.