Before Java 15, Writing SQL, HTML, JSON or any Polyglot scripts in String were difficult. It was ugly and difficult to read.
For example :
Following HTML in Java :
OR
Following SQL in Java :
lot's of concatenation and escapes, It's difficult to read and write.
With "JEP 378: Text Blocks" introduced in Java 15 ( Java 17 LTS), We can use two dimensional block of text.
for example, above code can be rewritten in following way:
Following HTML in Java 17 :
Following SQL in Java 17 :
This way ,It's easy to read and write strings in Java.
More Details on :JEP-378
Happy Codding !!
Top comments (0)