New way to Use Strings in Java 17

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

原文链接:New way to Use Strings in Java 17

© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容