Scrivio Interview library
ConceptFoundations5 min read · updated 12 November 2026

List the most useful features added between Java 9 and Java 17 for everyday code, with the release each became final.

The most useful everyday features from Java 9 to 17 are: modules, the List.of and Map.of factories, JShell and private interface methods in Java 9; var for local variables in 10; the standard HttpClient, new String methods such as isBlank, strip and lines, and running single-file programs in 11; switch expressions and helpful NullPointerException messages in 14; text blocks in 15; records and pattern matching for instanceof in 16; and sealed classes in 17. Together they make code shorter and safer without changing how Java feels.

Why this question is asked

Many teams jumped from Java 8 straight to 17, so they skipped eight releases of small improvements at once. Interviewers ask this question to see whether we actually use modern Java or still write Java 8 with a newer runtime. Knowing the release for each feature also matters when a library targets an older version. In this answer, we will walk through the releases in order, show each feature in a line or two of code with its result, and finish with a table to remember them.

1Java 9: Collection Factories, JShell and Private Interface Methods

Java 9's headline was the module system, but in everyday code the collection factories are what we use most. They create small immutable collections in one call. JShell is an interactive shell for trying out code without writing a class. Private interface methods let default methods share helper code inside the interface.

Java
List<String> days = List.of("Mon", "Tue"); // immutable
Map<String, Integer> ports = Map.of("http", 80, "https", 443);
days.add("Wed"); // UnsupportedOperationException
List.of("a", null); // NullPointerException: nulls not allowed
// jshell> "hello".toUpperCase()
// $1 ==> "HELLO"
interface Greeter {
default String hi(String n) { return wrap("Hi " + n); }
default String bye(String n) { return wrap("Bye " + n); }
private String wrap(String s) { return "[" + s + "]"; } // Java 9
}

Notice that these collections reject nulls and changes, unlike Arrays.asList. That is safer, but it can surprise code that later tries to add to them. Java 9 also added Stream.takeWhile and dropWhile and Optional.ifPresentOrElse.

2Java 10 and 11: var, HttpClient and String Methods

Java 10 introduced var for local variables: the compiler infers the type from the right-hand side, so the variable is still statically typed. Java 11, the first LTS after 8, added a standard HTTP client with HTTP/2 support, several String methods, and the ability to run a single source file directly with java Hello.java.

Java
var orders = new HashMap<String, List<Order>>(); // type is HashMap<String, List<Order>>
HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> r = client.send(
HttpRequest.newBuilder(URI.create("https://example.com")).build(),
HttpResponse.BodyHandlers.ofString());
System.out.println(r.statusCode()); // 200
" ".isBlank(); // true
" hi ".strip(); // "hi" (Unicode-aware trim)
"a\nb\nc".lines().count(); // 3
"ab".repeat(3); // "ababab"
// $ java Hello.java runs a one-file program without javac

Notice that strip() differs from trim(): trim() only removes characters up to the space code, while strip() removes all Unicode whitespace. Java 10 also added List.copyOf and orElseThrow() without arguments, and Java 11 added Files.readString and writeString.

3Java 14 and 15: Switch Expressions, Helpful NPEs and Text Blocks

Switch expressions, final in Java 14, return a value and use arrow labels without fall-through. Helpful NullPointerException messages, on by default from 15 after arriving in 14, tell us exactly which reference was null. Text blocks, final in 15, are multi-line string literals.

Java
int days = switch (month) {
case FEBRUARY -> 28;
case APRIL, JUNE, SEPTEMBER, NOVEMBER -> 30;
default -> 31;
};
order.getCustomer().getAddress().city();
// Cannot invoke "Address.city()" because the return value of
// "Customer.getAddress()" is null
String sql = """
SELECT id, name
FROM users
WHERE active = true
""";

Notice how much time the NPE message saves: before, we only got a line number and had to guess which of three calls returned null.

4Java 16 and 17: Records, Pattern Matching and Sealed Classes

Records, final in Java 16, are classes for plain data: the compiler writes the constructor, accessors, equals, hashCode and toString. Pattern matching for instanceof, also final in 16, tests and casts in one step. Sealed classes, final in 17, restrict which classes may extend a type, which lets the compiler know every subtype. Java 16 also added Stream.toList().

Java
record Point(int x, int y) {}
Point p = new Point(1, 2);
System.out.println(p); // Point[x=1, y=2]
System.out.println(p.equals(new Point(1, 2))); // true
Object o = "hello";
if (o instanceof String s && s.length() > 3) {
System.out.println(s.toUpperCase()); // HELLO, no cast needed
}
sealed interface Shape permits Circle, Square {}
record Circle(double r) implements Shape {}
record Square(double side) implements Shape {}
Everyday features from Java 9 to 17
ReleaseFeatures to know
9Modules, List.of and Map.of, JShell, private interface methods
10var for local variables
11 (LTS)HttpClient, isBlank, strip, lines, repeat, java File.java
14Switch expressions, helpful NullPointerException messages
15Text blocks
16Records, pattern matching for instanceof, Stream.toList()
17 (LTS)Sealed classes

Notice how these three work together: records describe data, sealed interfaces list the possible kinds, and pattern matching takes them apart. Java 21 completes the picture with pattern matching in switch.

5Follow-up questions

Is var dynamic typing?

No. The compiler infers the type once, at compile time, and the variable keeps that type. var list = new ArrayList<String>(); is exactly an ArrayList<String>. It only works for local variables with an initializer, not for fields, parameters or return types.

Why did these features take several releases each?

Since Java 10 the JDK uses preview features: a feature ships in a release as a preview, must be enabled with --enable-preview, and becomes final a release or two later after feedback. Records were previewed in 14 and 15 and became final in 16, for example.

Which of these features can we use if a library must still support Java 11?

Everything up to 11: the collection factories, var, HttpClient and the String methods. Switch expressions, text blocks, records and sealed classes need the code to be compiled for 14 to 17 or later.

6Conclusion

In this answer, we walked through the everyday features from Java 9 to 17 with their releases: collection factories, JShell and private interface methods in 9, var in 10, HttpClient and new String methods in 11, switch expressions and helpful NPE messages in 14, text blocks in 15, records and pattern matching for instanceof in 16, and sealed classes in 17. They make Java code shorter and safer, and the last three combine into a new style of modelling data that Java 21 completes.

What to say in the interviewAbout 80 seconds aloud

Open with

Going release by release: Java 9 is best known for modules, but day to day I use List.of, Set.of and Map.of to create small immutable collections, and JShell for trying things out, and it allowed private methods in interfaces so default methods can share helpers.

Then, if they want more

Java 10 added var for local variables, which is still static typing, just inferred. Java 11, the LTS, brought the standard HttpClient with HTTP/2, String methods like isBlank, strip, lines and repeat, Files.readString, and running a single source file with java Hello.java.

Java 14 made switch expressions final, with arrow labels and no fall-through, and added helpful NullPointerException messages that tell you exactly which reference was null. Java 15 made text blocks final, which is great for SQL and JSON. Java 16 made records and pattern matching for instanceof final, and added Stream.toList.

And Java 17, the next LTS, finalised sealed classes, which restrict which classes can implement an interface. Those last three fit together: records for data, sealed types for the set of possibilities, and patterns to take them apart, which Java 21 completes with pattern matching for switch.

Most of these went through preview releases first, which is why their final release is later than when people first heard of them.

About this answer

Last updated
12 November 2026
Versions it names
Java 9, Java 10, Java 11, Java 16
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "List the most useful features added between Java 9 and Java 17 for everyday code, with...": https://scrivio-interview-library.netlify.app/java/java-versions/c25ad40ede/