Java String isEmpty()方法示例。
如果当前字符串的长度为0,则String类的isEmpty()方法返回true。
示例
import java.lang.*;
public class StringDemo {
public static void main(String[] args) {
String str = "nhooo";
//打印字符串的长度
System.out.println("length of string = " + str.length());
//检查字符串是否为空
System.out.println("is this string empty? = " + str.isEmpty());
}
}输出结果
length of string = 14 is this string empty? = false
热门推荐
10 年终聚餐祝福语简短独特
11 哥哥祝福语简短霸气句子
12 简短祝福语蛋糕简笔画
13 新婚抖音祝福语简短
14 分手快乐祝福语简短
15 古风祝福语唯美简短亲情
16 生日祝福语简短蛋糕上
17 发给女儿生日简短祝福语
18 送师姐的祝福语简短