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

Tutorial Básico de Java

Controle de fluxo do Java

Array do Java

Java orientado a objetos (I)

Java orientado a objetos (II)

Java orientado a objetos (III)

Tratamento de Exceções Java

Lista (List) do Java

Java Queue (fila)

Conjunto Map do Java

Conjunto Set do Java

Entrada e saída do Java (I/O)

Reader do Java/Writer

Outros tópicos do Java

Métodos e exemplos de uso do Java String isEmpty()

Java String (String) Methods

The Java String isEmpty() method checks if the string is empty.

The syntax of the isEmpty() method 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:Uninitialized strings are not empty strings. If isEmpty() is used on uninitialized strings, an error will be thrown.

Java String (String) Methods