.isEmpty()
Anonymous contributor
Anonymous contributor1 total contribution
Anonymous contributor
Published Mar 4, 2023
Contribute to Docs
The .isEmpty()
method returns true
if a string has no content. It returns false
if the string has content.
Syntax
string.isEmpty();
string
: The string to be checked for content.
Example 1
The example below applies the .isEmpty()
method to the strings drink
and food
:
// isStringEmpty.javaclass isStringEmpty {public static void main(String[] args) {String drink = "lemonade";String food = "";System.out.println(drink.isEmpty());System.out.println(food.isEmpty());}}
This will print the following output:
falsetrue
All contributors
- Anonymous contributorAnonymous contributor1 total contribution
- Anonymous contributor
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.