You are currently viewing Java 11 features

Java 11 features

  • Post author:
  • Post category:Java
  • Post comments:0 Comments
  • Post last modified:February 1, 2024

Java 11 is the second LTS release after Java 8. Since Java 11, Oracle JDK would no longer be free for commercial use. You can use it in developing stages but to use it commercially, you need to buy a license.
Oracle will not be providing free long-term support (LTS) for any single Java version since Java 11.

Some of the important Java 11 features are:

  • Running Java File with single command
  • New utility methods in String class
  • Local-Variable Syntax for Lambda Parameters
  • Reading/Writing Strings to and from the Files

Running Java File with single command

One major change is that you don’t need to compile the java source file with javac tool first. You can directly run the file with java command and it implicitly compiles. 

New utility methods in String class

isBlank(): This is a boolean method. It just returns true when a string is empty and vice-versa.
lines(): This method is to return a collection of strings that are divided by line terminators.
repeat(n): Result is the concatenated string of original string repeated the number of times in the argument.
strip(): It is used to remove the white spaces which are in front and back of the string
stripLeading(): It is used to remove the white space which is in front of the string
stripTrailing(): It is used to remove the white space which is in the back of the string

Local-Variable Syntax for Lambda Parameters

Java 11 allows var to be used to declare the formal parameters of an implicitly typed lambda expression. 

Reading/Writing Strings to and from the Files

Java 11 strives to make reading and writing of String convenient. It has introduced the following methods for reading and writing to/from the files:

  • readString()
  • writeString()

Leave a Reply