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 M退休祝福语结婚简短
16 男生打球祝福语简短霸气
17 财神祝福语简短情话文案
18 周末祝福语简短老师的话