Java has come a long way since Java 8. The most used Java version nowadays is Java 11, which is a Long-Term-Support (LTS) release. After Java 8, Oracle released Java 9 and Java 10, making them Non-Long-Term-Support (Non LTS) releases. What this means is that instead of releasing them as major updates to Java 8, Oracle decided to classify the releases as Non-LTS releases—whereas LTS releases represent major improvements to the language.
In general, LTS releases are not announced within a 3-year period. Even though the current Java version available is Java 16, Java versions 12, 13, 14, 15 and 16 were all Non-LTS releases. Non-LTS releases of Java don’t receive wide acceptance in the Development world, though this may change in the future. This blog post explores some of the features added after Java 8 (though not specifically added in Java 11).
Shebang files or Single-file programs are very popular in UNIX-based OS systems and other modern-day languages (e.g., Python, Ruby). These single-file programs are used to create utility functions (e.g., an executable).
Java 11 includes this single-file program feature, which is useful for creating a utility if you’re unfamiliar with Linux-based utilities or scripting. Single-file programming was released as part of “JEP 330: Launch Single-File Source-Code Programs.” (JEP stands for JDK Enhancement Proposals)
Most of us would be using IDEs (e.g., Eclipse or Intellij Idea) which has a built-in compiler. Beginners might not be familiar with a compiler like javac.
Using javac command (e.g., javac <<java-filename>>) to compile the Java program will result in a .class file in the same location as the Java file. The java command that will execute the Java program from the compiled .class file is java <<class-name>>.
With this new feature, we no longer need to use the javac command. You can write your utility in Java and run it, using just java <<class-name>>. The screenshot below illustrates an example.
Java 11 introduced some cool methods, including: repeat (), lines (), strip (). See the documentation and examples below.
Repeat () method takes an integer as count for the number of times a string must be repeated. In Java 8, you may have ended up creating a utility function that will loop through the count and appending the string one by one using arrays. Apart from that you would also have to handle conditions like negative count, out of memory situations, etc. Repeat () will throw IllegalArgumentException if a negative count is passed. Repeat () will throw OutOfMemoryError if “Integer.MAX_VALUE / count < String length”.
Lines () returns a stream of Strings: one per line for a multi-line string. In Java 8 and earlier, you may have created a utility to split a multi-line String using StringReader—which may be error-prone and not a performance-optimized solution.
Strip () removes the empty space in the leading and trailing of a string. In Java 8, we would have used trim () method. However, strip () was implemented with Unicode awareness and an optimized solution compared to trim (). So, strip () is several times faster than trim ().
A default method toArray () was added to the Collection interface. In Java 8 and earlier, converting a list of elements into an array required a two-step process: one for creating the array with a length of the size of the list, and then invoking the toArray() method to copy the contents from the List to Array. With this new default toArray () method, these steps are reduced to one.
Var keyword is a popular addition to Java 10. This is a powerful feature that other modern-day languages have. In Java 8, every variable needed to be defined by its type, resulting in boilerplate code with little readability. With the introduction of var keyword, Java code is more readable. Additionally, prior to Java 11, you could not use var in a lambda. This, too, has been taken care of in Java 11.
The next LTS release is Java 17, which is scheduled to be released in September of 2021. Stay tuned for all the cumulative enhancements and features of Java 12, 13, 14, 15 and 16. With all these enhancements, Java is becoming forever young. In the meantime, if you have any questions about any version of Java, please feel free to reach out to us at any time. We’d love to help you get started.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
|cookielawinfo-checbox-analytics||11 months||This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".|
|cookielawinfo-checbox-functional||11 months||The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".|
|cookielawinfo-checbox-others||11 months||This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.|
|cookielawinfo-checkbox-necessary||11 months||This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".|
|cookielawinfo-checkbox-performance||11 months||This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".|
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.