Check if empty

You can check if a String is empty in a few ways.

The one you should already have been able to figure out1 is that you can get the .length of a String and see if that is zero.

void main() {
    String textMessages = "";
    System.out.println(
        textMessages.length() == 0
    );
}

But another is to use the explicitly defined .isEmpty() method.

void main() {
    String textMessages = "";
    System.out.println(
        textMessages.isEmpty()
    );
}

This can be more convenient. Both to write, as it is fewer characters to type, and to read later on.

1

Again, no shame if not. I didn't exactly call attention to it.