Java String isEmpty() method example

HQ » Java Tutorial » java.lang » String » isEmpty() method example
Java String isEmpty() method example 2018-02-19T12:56:12+00:00

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 :


Contact Info


Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.