java.lang.String isEmpty()

Description :

This java tutorial shows how to use the isEmpty() method of java.lang.String class. This method returns boolean data type which signifies if the String length is 0 or not. This method generally checks if the string is empty (string length is 0).

Method Syntax :

public boolean isEmpty()

Method Returns :

This method returns boolean datatype depending if the String length is zero or not. This method returns true if and only if the length of the String is zero, otherwise false.

Compatibility Version:

Requires Java 1.6 and up

Exception :

No Exception is expected as specified on java api.

Java Code Example :

This example source code demonstrates the use of isEmpty() method of String class. We have also added on this java code that checks the length of the String.

Sample Output :

Running the isEmpty() example source code will give you the following output

java string isempty method example

java string isempty method example

Exception Scenario :

No Exception specified on Java API

Suggested Reading List :