Nearby lessons

116 of 125

Java 11 Features

📌 What You Will Learn
  • 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:

In simple words: `isBlank`, `strip`, `repeat` and `lines` are one-line helpers that replace loops you used to write by hand — for example, "AB".repeat(3) gives "ABABAB" in a single call.
Example02
Loading editor…

strip() vs trim() — Small but Important

Pointtrim() (old)strip() (Java 11)
Introduced inJava 1.0Java 11
RemovesSpaces with code <= 32 (ASCII spaces)All Unicode spaces (including tab, newline)
StandardOld, ASCII-basedModern, Unicode-aware
Best choiceLegacy codeNew code
In simple words: `strip()` removes all Unicode spaces, while `trim()` only removes ASCII spaces — for new code always prefer strip(), because it also clears tabs, newlines and other Unicode whitespace.

var in Lambda Parameters

Java 11 allows var inside lambda parameters — useful when you want to add annotations to the parameter:

Trainer's Note: The real use of var in lambdas is when you need annotations on the parameter, like (@NotNull var s) -> .... Otherwise, plain s is shorter. So this feature is more about consistency than daily use.
Example04
Loading editor…

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.

In simple words: `java Hello.java` compiles the file in memory and runs it in one command — no javac step and no .class file left behind, which is perfect for quick tests and small scripts.
Example05
Loading editor…

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:

Example06
Loading editor…

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.

📝 Key Takeaways
  • 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.

🧠 Test Your Knowledge

8 Questions
Progress: 0 / 8

Finished this lesson?

Mark it as complete to track your progress and see technology completion stats.