English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
يتحقق طريقة isEmpty() لـ Java String من أن القائمة فارغة.
نموذج isEmpty() للقوائم المفتوحة هو:
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:The uninitialized string is not an empty string. If isEmpty() is used on an uninitialized string, an error will be thrown.