EN
Java - check if string is empty
0 points
In this article, we would like to show you how to check if the string is empty using string isEmpty()
method in Java.
Quick solution:
xxxxxxxxxx
1
String text = "";
2
System.out.println(text.isEmpty()); // true
xxxxxxxxxx
1
public class Example {
2
3
public static void main(String[] args) {
4
String text = "some text here...";
5
String emptyString = "";
6
7
System.out.println(text.isEmpty()); // false
8
System.out.println(emptyString.isEmpty()); // true
9
}
10
}
Output:
xxxxxxxxxx
1
false
2
true