Java String isEmpty() Method
Example
Find out if a string is empty or not:
public class MyClass {
public static void main(String[] args) {
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:
|
---|
❮ String Methods