Java 14 – Text Blocks (Second Preview)

JEP-355 was an excellent change brought in Java 13 as a preview to simplify the HTML code piece in Java. But, now, Java 14 has come up with a second preview in Text Blocks with two more newly added escape sequences. This change is present under JEP-368. You can download Java 14 by clicking here.

  • \<end-of-line> for newlines (line terminator)
  • \s for single space (white space)


Java 14 - Text Blocks - Key Change for HTML...!!! Click To Tweet

Check out: JAVA 13 Features with examples

JEP 368 – Text Blocks

In Java 13, JEP 355 allows you to create a multiline string or you can say a text-block. You need to write a multiline string inside a pair of triple double-quotes. But, now, in Java 14, JEP 368 has new line & white space sequences too. Let’s check it.

 

Let’s see the below code that differentiates between code before Java13, In Java13 and finally IN JAVA 14

 

Output:

Java 14 - Text Blocks - Key Change for HTML...!!! Click To Tweet

 

Other Useful References:

 

Related Posts:

[wcp-carousel id=”5342″]

Leave a Reply

Your email address will not be published.Required fields are marked *

Facebook Twitter Instagram YouTube