Member-only story
Understanding Java 10: Key Features for Simplified Coding
Java, a well-known programming language, has been a part of the coding world for years, adapting and growing with each new version. In March 2018, Java 10 was released, introducing several important upgrades that made programming easier, faster, and more efficient. Let’s explore the major features of Java 10 in simple words, so you can understand and utilize them in your coding adventures.
Local-Variable Type Inference (var)
One of the biggest changes in Java 10 is the introduction of var
. This allows you to declare a variable without specifying its type. The compiler understands the type based on the value you assign to the variable.
var list = new ArrayList<String>(); // infers ArrayList<String>
var stream = list.stream(); // infers Stream<String>
Before Java 10, you would need to write the full declaration, like ArrayList<String> list = new ArrayList<String>();
, which is repetitive. Now, your code is cleaner and you don't have to repeat yourself.
Application Class-Data Sharing (CDS)
The Application Class-Data Sharing (CDS) feature helps to improve startup time and reduce memory footprint running Java applications. It allows you to share class metadata between different…