English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Java String isEmpty() method checks if the string is empty.
The syntax of the string isEmpty() method is:
string.isEmpty()
Here, string is an object of the String class.
Without any parameters
If the string is empty (length is 0)Returns true
If the string is not emptyReturns false
class Main { public static void main(String[] args) { String str1 = "Java Programming"; String str2 = ""; System.out.println(str1.isEmpty()); // false System.out.println(str2.isEmpty()); // true } }
Note:An uninitialized string is not an empty string. If isEmpty() is used on an uninitialized string, an error will be thrown.