bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java String isEmpty() Method

❮ String Methods

Example

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

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
  • true - The string is empty (length() is 0)
  • false - The string is not empty

Previous

Java String indexOf() Method

Next

Java String join() Method