Posts

Showing posts with the label java 17

What's New in Java 17: A Comprehensive Overview

  What's New in Java 17: A Comprehensive Overview Java 17, released in September 2021, is a significant Long-Term Support (LTS) release, providing a host of new features and enhancements aimed at improving performance, stability, and developer productivity. Here's a look at the major changes in Java 17, along with examples to illustrate the key updates. 1. Sealed Classes Introduction : Sealed classes and interfaces provide a way to restrict which classes or interfaces can extend or implement them. This feature allows developers to create a more controlled hierarchy and enhance the safety and readability of the code. Example : java Copy code // Sealed class declaration public sealed class Shape permits Circle, Rectangle { } // Subclass of Shape public final class Circle extends Shape { private final double radius; public Circle ( double radius) { this .radius = radius; } } // Another subclass of Shape public final class Rectangle extends Shape ...

Lambda expressions - implicitly typed parameters

For formal parameters of implicitly typed lambda expressions, allow the reserved type name `var` to be used, so that:     (var x, var y) -> x.process(y) is equivalent to:     (x, y) -> x.process(y) An implicitly typed lambda expression must use `var` for all its formal parameters or for none of them. In addition, `var` is permitted only for the formal parameters of implicitly typed lambda expressions --- explicitly typed lambda expressions continue to specify manifest types for _all_ their formal parameters, so it is not permitted for some formal parameters to have manifest types while others use `var`. The following examples are illegal:     (var x, y) -> x.process(y)         // Cannot mix 'var' and 'no var' in implicitly typed lambda expression     (var x, int y) -> x.process(y)     // Cannot mix 'var' and manifest types in explicitly typed lambda expression In theory, it would be...

Java 17 Features | What's new in Java 17?

Java 17 Features JDK 17 is the open-source reference implementation of version 17 of the Java SE Platform as specified by JSR in the Java Community Process. Some of the important Java 17 features are: Text Blocks – JEP 355 New Methods in String Class for Text Blocks Switch Expressions Enhancements – JEP 354 Reimplement the Legacy Socket API – JEP 353 Dynamic CDS Archive – JEP 350 ZGC: Uncommit Unused Memory – JEP 351 FileSystems.newFileSystem() Method Support for Unicode 12.1 DOM and SAX Factories with Namespace Support Some More java 17 features are coming up. We will discuss once openjdk Java Community Process released some information. Features