Posts

JAVA 11 – New String methods

JAVA 11 – New String methods In this blog, we will discuss about all six new methods which got introduced with JDK 11. isBlank(): returns true if string is empty otherwise false. White spaces code will also be considered as empty string. // Java 8 Predefine Functional Interface              // The best way to learn JAVA 8 is to implement it wherever you can...              BiConsumer<String, String> display = ( msg1 , msg2 ) -> System. out .println( msg1 + msg2 );              // local variable type inference              var msg = "Welcome to waheedtechblog page" ;              // String msg = "Welcome to waheedtechblog page"; both are same ...

Java 10 - Local Variable Type Inference

Java 10 - Local Variable Type Inference In one of my previous blog, I have already discussed about Type Inference. If you don’t have the idea about Type Inference then you can check my blog here . If we want to understand Type Inference in one line then we can say that It is the capability of the compiler to automatically detect the datatype of a variable at the compiler time. What is Local Variable type inference? Java 10 added new feature that allows the developer to skip the type declaration associated with local variables (those defined inside method definitions, initialization blocks, for-loops, and other blocks like if-else), and the type is inferred by the JDK. It will, then, be the job of the compiler to figure out the datatype of the variable. Until Java 9 , we had to define the type of the local variable. E.g.: String message = “Welcome to Waheedtechblog.com”; The above statement is right as that’s how things have been since the inception of java b...