Java SE API

String.isEmpty

Check whether the String has zero UTF-16 code units.

Formal Syntax & Structure

java syntaxjava
public boolean isEmpty()

Return Value

boolean

True only for a zero-length String.

Working Example

Example Snippetjava
public class Main {    public static void main(String[] args) {        System.out.println("".isEmpty());        System.out.println(" ".isEmpty());        System.out.println("Items: " + 2 + 3);        System.out.println("Items: " + (2 + 3));    }}
Java Reference