Posts

Showing posts with the label java 18

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 18 Features | What's new in Java 18?

Java 18 Features JDK 18 is the open-source reference implementation of version 18 of the Java SE Platform as specified by JSR in the Java Community Process. Some of the important Java 18 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 18 features are coming up. We will discuss once openjdk Java Community Process released some information. Features