Of course! It seems you're looking for information on Java 10, which was a significant, albeit smaller, release in the history of Java's evolution. It was part of the new, faster release cadence (the "time-based" releases) and introduced a key feature that developers had been waiting for.

Let's break down Java 10, focusing on its most important feature and other changes.
Java 10: The "Local-Variable Type Inference" Release
Java 10 was released on March 20, 2025. Its main goal was to make the code more concise and readable without sacrificing type safety. It was a relatively small release, containing only 12 JEPs (JDK Enhancement Proposals), with one being the star of the show.
I. The Main Event: JEP 286 - Local-Variable Type Inference (var)
This is the feature most people associate with Java 10. It allows you to declare local variables (variables inside methods, constructors, or blocks) without explicitly specifying their type. The compiler infers the type from the initializer expression.
Before Java 10 (The Old Way)
You had to explicitly declare the type on both the left and the right side of the assignment, which could be verbose, especially with complex generic types.
// Basic types String message = "Hello, Java 10!"; int count = 100; // Complex generic types (very verbose) Map<String, List<Map<String, Object>>> dataMap = new HashMap<>();
With Java 10 (The var Keyword)
You can now use the var keyword, and the compiler will figure out the type for you. The type is still static and checked at compile-time. It's not dynamic typing like in JavaScript or Python.
// Basic types - much cleaner! var message = "Hello, Java 10!"; var count = 100; // Complex generic types - a huge improvement in readability! var dataMap = new HashMap<String, List<Map<String, Object>>>();
How var Works: The Rules
-
Local Variable Only:
varcan only be used for local variables with an initializer. It cannot be used for:- Method parameters
- Constructor parameters
- Fields (instance or static variables)
- Return types of methods
// COMPILE ERRORS! public void process(var data) { } // Error: 'var' is not allowed here private var myField = 10; // Error: 'var' is not allowed here public var myMethod() { ... } // Error: 'var' is not allowed here -
Initializer is Mandatory: The variable must be initialized at the same time it's declared.
// COMPILE ERROR! var number; // Error: cannot use 'var' on variable without initializer number = 10;
-
Type is Inferred at Compile-Time: This is crucial.
varis just a syntactic sugar. The bytecode generated is identical to the explicit type version. There is no runtime performance penalty.var name = "Java"; // Compiler infers 'String' name = 10; // COMPILE ERROR! Incompatible types: int cannot be converted to String
-
Lambdas are an Exception: You cannot use
varfor a lambda expression itself, because the type is complex and comes from the surrounding context (the functional interface).// COMPILE ERROR! var myRunnable = () -> System.out.println("This won't work."); // The correct way is to specify the functional interface type: Runnable myRunnable = () -> System.out.println("This works.");
Benefits of var
- Conciseness: Reduces boilerplate code, especially for variables with long, generic types.
- Readability: Can make code easier to read by focusing on the variable name and its initial value rather than the often-obvious type.
- Refactoring: If you change the type of the initializer, you don't need to change the type declaration on the left side.
When to Use (and NOT Use) var
DO Use var for... |
DON'T Use var for... |
|---|---|
Variables with obvious, clear types. (var name = "Alice";) |
Variables whose type is not immediately obvious from the initializer. |
| Reducing verbosity with complex generics. | Making code less readable. If var obscures the type, don't use it. |
Reducing boilerplate in loops. (for (var item : list)) |
When the type is important for code clarity. |
| Public APIs (as it's not allowed for parameters or returns). |
II. Other Notable Features in Java 10
While var was the star, Java 10 included other important improvements.
JEP 296 - Consolidate the JDK Forest
This was a significant internal change. Before Java 10, the JDK repository was split into multiple code repositories (the "JDK Forest"). This made development and maintenance difficult. JEP 296 consolidated all these repositories into a single one, streamlining the development process for the OpenJDK community.
JEP 304 - Garbage-Collector Interface
This was a foundational change for future garbage collectors. It introduced a clean, well-defined API for garbage collectors. This allows new garbage collectors to be developed and integrated into the JDK more easily without having to modify the core JVM code extensively. This is an "under-the-hood" change that benefits the long-term health of the platform.
JEP 307 - Parallel Full GC for G1
The G1 Garbage Collector was designed to be a low-pause collector. However, its "full garbage collection" (a major stop-the-world event) was still single-threaded, which could cause long pauses on large heaps. Java 10 improved this by making the full GC run in parallel, significantly reducing pause times for large applications using G1.
Application Class-Data Sharing (CDS) for the JVM Compiler Interface (JVMCI)
This is a highly technical but performance-oriented feature. It extends the existing CDS feature, which stores classes in a shared archive to speed up application startup, to work with the JVMCI. JVMCI allows a JIT (Just-In-Time) compiler to be implemented in Java itself (e.g., the GraalVM compiler). This feature improves the startup time of these advanced JIT compilers.
III. How to Use Java 10
If you want to experiment with Java 10, you can download it from the Adoptium (formerly AdoptOpenJDK) website or use a version manager like SDKMAN!.
# With SDKMAN! $ sdk install java 10.0.2-open $ sdk use java 10.0.2-open
Summary: Java 10 in a Nutshell
| Feature | JEP | Description |
|---|---|---|
| Local-Variable Type Inference | 286 | The star of the show. Allows var for local variable declaration to reduce verbosity and improve readability. |
| Consolidated JDK Repository | 296 | Merged all JDK source code repositories into one, simplifying development. |
| GC Interface | 304 | Created a standard API for garbage collectors, making it easier to add new ones to the JVM. |
| Parallel Full GC for G1 | 307 | Made G1's full garbage collection run in parallel, reducing pause times on large heaps. |
| CDS for JVMCI | 307 | Extended Class-Data Sharing to work with the JVM Compiler Interface, improving startup for JIT compilers. |
Java 10 was a crucial step in modernizing Java. While var was the most visible change, the other improvements laid the groundwork for faster innovation and better performance in subsequent releases. It set the stage for the even more significant features that would come in Java 11 and beyond.
