Example
Determine whether a string is empty or not.
String myStr1 = "Hello";
String myStr2 = "";
System.out.println(myStr1.isEmpty());
System.out.println(myStr2.isEmpty());
|
Definition and Usage
The isEmpty() method determines if a string is empty or not.
It returns true if the string’s length is 0, and false otherwise.
Syntax
Parameters
None.
Technical Details
|
Return
|
A boolean value is returned:
- true indicates that the string is empty (length() is 0).
- false indicates that the string is not empty.
|