Check if string is empty in java

By | April 19, 2020

We can check if string is empty, blank or null using below methods.

1 StringUtils

2. String.length() method

3. isEmpty() method


1. StringUtils:

Apache string utility is giving isBlank() method. It is used as below.


2. String.length():

When a string length is equals to ‘0’ then it is an empty string.


str is empty


3. isEmpty method:

This method is present in the String class. It returns true if, and only if, length() is 0.



Tags: check if string is empty, check empty string in java

Recommended Posts:

Common exceptions in selenium

Covert String to int in Java

Selenium Java links

Java interview questions for testers

SQL Quick Reference Guide for testing interviews

Leave a Reply

Your email address will not be published. Required fields are marked *