Posts

Showing posts with the label Java 11

New Features in Java 11 Explained in Detail

Java 11, is the latest long-term support (LTS) version of the Java programming language. It brings along several exciting features and improvements. In this blog post, we’ll take high level look into the New Features in Java 11. Local Variable Syntax for Lambda Parameters One of the most important features in Java 11 is the ability to use the var keyword for lambda parameters. This allows for more concise and readable code when working with lambda expressions. Java 10 introduced the Local Variable Type Inference feature . However, the var keyword could not be used with lambda expressions. So, you would need to write a lambda expression as follows: (int a, int b) -> a + b This code can be rewritten in Java 11 as follows: (var a, var b) -> a + b   HTTP Client Improvements Java 11 introduces a new and modern HTTP client API that supports HTTP/1.1, HTTP/2, and WebSocket. This new client offers a more flexible and efficient way to make HTTP requests and process responses. ...

Java 11 String enhancements with examples

Java 11 has made some significant improvements to the String class. In this article, we will be exploring the Java 11 String enhancements strip Java 11 has added a new strip method to the String class. This method removes all the leading and trailing whitespaces in a String. Consider the following code: String input = " Hello World ";System.out.println(input);String output = input.strip();System.out.println(output); This code produces the following output: Hello WorldHello World In addition to strip , the String class also has a trim method which also removes all leading and trailing whitespaces. This method exists right from the early versions of Java and so has some limitations. Earlier, the ASCII character set was used. So, trim can only remove whitespaces represented by ASCII characters. However, later on Java adopted the Unicode character set.  Unicode has some additional characters that represent whitespace. The trim method cannot remove these whitespaces....