Related differences

Java 14 vs Java 15Java 15 vs Java 16

Ques 11. What is Java 15?

Released on September 15, 2020.

There are a few new features and updates have been provided here:

The JDK class library, Text Blocks, performance changes, experimental, preview, and incubator features, deprecations and deletions, and finally, other changes that we rarely come into contact with.

But that's not all: A total of 14 JDK Enhancement Proposals (JEPs) have made it into this release.

Is it helpful? Add Comment View Comments
 

Ques 12. What is Text Blocks or Multi-line string in Java 15?

Until now, when we wanted to define a multi-line string in Java, it usually looked like this:

String sql =
" SELECT id, title, text\n"
+ " FROM Article\n"
+ " WHERE category = \"Java\"\n"
+ "ORDER BY title";

Starting with Java 15, we can notate this string as a "text block":

String sql = """
SELECT id, title, text
FROM Article
WHERE category = "Java"
ORDER BY title""";

Is it helpful? Add Comment View Comments
 

Ques 13. What is the Garbage Collector ZGC + Shenandoah in Java 15?

The requirements for modern applications are becoming increasingly demanding. With memory requirements ranging from gigabytes to terabytes, they may have to achieve response times in the single-digit millisecond range.

Conventional garbage collectors (such as the allrounder G1) with stop-the-world phases of a hundred milliseconds and more are not optimally suited to such requirements.

Aiming to eliminate stop-the-world pauses as much as possible (by doing most of the work in parallel with the running application), or at least reduce them to a few milliseconds, Oracle and RedHat have developed two new garbage collectors that have been shipped as preview features since Java 11 and 12, respectively.

As of Java 15, they are ready for productive use and will hopefully make the Java platform attractive to even more developers.

Is it helpful? Add Comment View Comments
 

Ques 14. What is ZGC: A Scalable Low-Latency Garbage Collector in Java 15?

The Z Garbage Collector, or ZGC, promises not to exceed pause times of 10 ms while reducing overall application throughput by no more than 15% compared to the G1GC (the reduction in throughput is the cost of low latency).

ZGC supports heap sizes from 8 MB up to 16 TB.

The pause times are independent of both the heap size and the number of surviving objects.

Like G1, ZGC is based on regions, is NUMA compatible and can return unused memory to the operating system.

You can configure ZGC with a "soft" heap upper limit (VM option -XX:SoftMaxHeapSize): ZGC will only exceed this limit if necessary to avoid an OutOfMemoryError.

To activate ZGC, use the following VM option:

-XX:+UseZGC

Is it helpful? Add Comment View Comments
 

Ques 15. What is Shenandoah: A Low-Pause-Time Garbage Collector in Java 15?

Just like ZGC, Shenandoah promises minimal pause times, regardless of the heap size.

You can read about exactly how Shenandoah achieves this on the Shenandoah wiki.

You can activate Shenandoah with the following VM option:

-XX:+UseShenandoahGC

Just like G1 and ZGC, Shenandoah returns unused memory to the operating system after a while.

There is currently no support for NUMA and SoftMaxHeapSize; however, at least NUMA support is planned.

Is it helpful? Add Comment View Comments
 

Most helpful rated by users: