This article is a continuation of Introduction to the New Generation Java Programming Guide (Java 12).
The book concludes with a commentary on the Amber project. The Amber project is an effort to extend the Java language to a better language, but at the time of publication of the original, it seems that there were many undecided versions of Java that could be used. Of course, there are still some undecided translations that have been released. Although it is an Amber project that includes such ** future functions **, the book explains the following five.
Unlike when the book was released, Java 14 has already been released. Of the above features in Java14
Can be used as a Preview function.
Of the above, the one I personally want to officially release as soon as possible is the text block. The text block feature has been released as a Preview version from Java 13, but it has not yet been officially released in Java 14 and is expected to be officially released in Java 15. When defining a string literally in Java, enclose it in double quotes ("). In a text block, you can define line breaks, double quotes, etc. without using escape sequences by enclosing the string in three double quotes ("" ").
For example
<HTML>
<BODY>
<H1>Meaning of life</H1>
</BODY>
</HTML>
Until now to define a character string such as
String html = "<HTML>" +
"\n\t" + "<BODY>" +
"\n\t\t" + "<H1>Meaning of life</H1>" +
"\n\t" + "</BODY>" +
"\n" + "</HTML>";
I was doing like
String html = """
<HTML>
<BODY>
<H1>Meaning of life</H1>
</BODY>
</HTML>
""";
Can be written simply. You may be concerned about the indentation, but the same amount of whitespace as before the three closing quotation marks ("" ") is removed from the beginning of each line. As a result, you can generate the first string shown. In this way, the Amber project, which is proceeding with various useful functions, is summarized in an easy-to-understand manner, and I think that you can see how the Java language will evolve in the future just by reading it quickly.
This is the introduction of the new generation Java programming guide (Java language extension project "Amber" edition).
Recommended Posts