From the course: Migrating beyond Java 8

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Java 12 language and API features

Java 12 language and API features - Java Tutorial

From the course: Migrating beyond Java 8

Start my 1-month free trial

Java 12 language and API features

- [Instructor] Changes introduced in Java 12 were primarily focused on improvements to the JVM but the release did bring some new language features that we'll explore. Like the last release, Java 12 introduced new methods to the string class and that's where we're going to get started. Indent was one of the new methods added to string in Java 12. When we invoke the indent method, you'll see that it accepts an integer as an argument. This integer will determine the number of spaces added to the beginning of each line of our string. Basically, we're going to be prefixing white space to the beginning of each line of the string. It's pretty obvious Java 12's indent method is much easier than writing your own implementation. Moving on, we're going to take a look at the new transform method on the string class in Java 12. If we look at our implementation, you'll see that we take a function and a string and then we invoke the…

Contents