Posts

Showing posts with the label java 20

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

Image
Java 20 Features JDK 20 is the open-source reference implementation of version 20 of the Java SE Platform as specified by JSR in the Java Community Process. Some of the important Java 20 features are: Text Blocks – JEP 355 ZGC: Uncommit Unused Memory – JEP 351 Support for Unicode 12.1 DOM and SAX Factories with Namespace Support Improved interoperability with native code, to enable Java source code to call functions and use data types from other languages, in a way that is easier and has better performance than today. Virtual threads, a lightweight user-mode scheduled alternative to standard OS managed threads. Virtual threads are mapped to OS threads in many-to-many relationship, in contrast to many-to-one relationship from original green threads implementation in early versions of Java. Some More java 20 features are coming up. We will discuss once openjdk Java Community Process released some information. JDK 20 Features:

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...