![]() ![]() Starting with Java 15 they have become a standard feature of the language. In Java 13 and Java 14, text blocks could be used as feature preview. In this way the verbosity of the code decreases, and readability and ease of writing is improved. The formatting of multiline strings is more natural than in the past: it will no longer be necessary to use string concatenations, escape characters such as \n, and complex management of quotes and spaces. This feature allows strings to be defined on multiple lines using a new syntax. Then with Java 13, a new feature called text blocks has been introduced that allows us to use the String class in a more profitable and easier way. The compact strings introduced in Java 9 have undoubtedly made strings more performing. ![]() In the latest versions other improvements are being made to this fundamental class to make its use more efficient, simpler to use and less verbose. In addition, the memory management of these String objects is characterized by the reuse of instances already created through an internally-managed pool of strings. In fact, its objects are always immutable, and these can be instantiated with a simplified syntax that makes us avoid the verbosity of the new operator and the call to the constructor, as is standard for almost all other classes. String is undoubtedly the most used class in Java, and represents an exception among the classes of the standard library. The aim is to make the reader aware of how important it is to move forward from Java 8, explaining the enormous advantages that the latest versions of the language offer. These articles will guide the reader step by step to explore the most important features introduced starting from version 9. ![]() What you are reading is an article in a series titled “Going beyond Java 8”, inspired by the contents of my book “ Java for Aliens”. According to some surveys such as that of JetBrains, version 8 of Java is currently the most used by developers all over the world, despite being a 2014 release. ![]()
0 Comments
Leave a Reply. |