在 Java 中检查空或空值。
我们可以使用 StringUtils 类中的 isBlank() 方法检查特定 String 是否为空。此方法接受一个整型参数,如果给定字符串为空,则返回 true,否则返回 false。
示例
import org.apache.commons.lang3.StringUtils;
public class Sample {
public static void main(String args[]) {
String str = "";
Boolean bool = StringUtils.isBlank(str);
System.out.println(bool);
}
}
输出
true
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP