Checking for Null or Empty in Java.

Java 8Object Oriented ProgrammingProgramming

We can check whether a particular String is empty or not, using isBlank() method of the StringUtils class. This method accepts an integer as a parameter and returns true if the given string is empty, or false if it is not.

Example

Live Demo

import org.apache.commons.lang3.StringUtils;

public class Sample {
   public static void main(String args[]) {
      String str = "";
      Boolean bool = StringUtils.isBlank(str);
      System.out.println(bool);
   }
}

Output

true
raja
Published on 12-Feb-2018 11:49:22
Advertisements