Java String isEmpty() Method

❮ String Methods


Example

Find out if a string is empty or not:

String myStr1 = "Hello";
String myStr2 = "";
System.out.println(myStr1.isEmpty());
System.out.println(myStr2.isEmpty());

Try it Yourself »


Definition and Usage

The isEmpty() method checks whether a string is empty or not.

This method returns true if the string is empty (length() is 0), and false if not.


Syntax

public boolean isEmpty()

Parameters

None.

Technical Details

Returns: A boolean value:
  • true - The string is empty (length() is 0)
  • false - The string is not empty

❮ String Methods
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.