English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Tutoriel de base Java

Contrôle de flux Java

Java tableau

Java orienté objet (I)

Java orienté objet (II)

Java orienté objet (III)

Gestion des exceptions Java

Java Liste (List)

Java Queue (file d'attente)

Java Map collectif

Java Set collectif

Entrée et sortie Java (I/O)

Reader Java/Writer

Autres sujets Java

Méthode d'utilisation de Java String isEmpty() et exemples

Java String (string) methods

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.

isEmpty() parameter

  • Without any parameters

isEmpty() return value

  • If the string is empty (length is 0)Returns true

  • If the string is not emptyReturns false

Example: Java string isEmpty()

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.

Java String (string) methods