Java 15 – Text Blocks

Previewed in Java 13 & 14, it is standardized in Java 15. Text Blocks are not a new concept, within coding languages, it can be seen in JavaScript,etc.  

What are text blocks? 

Text blocks are still strings. Started with 3 double quotes and ended 3 double quotes.  

General Q & A 

What can this be used for? 

You can include literal fragments of JSON, HTML, SQL, etc.

Output  

Can you indent within the text blocks? 

Output

Can you use escaping within text blocks? 

Output

Can you format the text blocks? 

Output

Code example can be found here.   

Final Thoughts 

This helps in writing better, readable code.  

2 thoughts on “Java 15 – Text Blocks

  1. Pingback: Java Versions & Features - Spaghetti Code Jungle

  2. Garrett Nery says:

    I’d like to thank you for the efforts you have put in penning this blog. I really hope to see the same high-grade content from you later on as well. In truth, your creative writing abilities has motivated me to get my own, personal blog now 😉

Leave a Reply

Your email address will not be published.