Checking for Null or Empty in Java.


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

Updated on: 30-Jul-2019

11K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements