目录
1.isEmpty
1.1.可以判断字符串是否为空或 null
1.2.可以判断Integer类型的数据是否为空
1.isEmpty
1.1.可以判断字符串是否为空或 null
@Testpublic void test() {/*** StringUtils.isEmpty 判断是空*/String username = "123456";System.out.println(StringUtils.isEmpty(username)); //false//username2为空,那么它是怎么判断的?String username2 = "";System.out.println(StringUtils.isEmpty(username2)); //true//username3为空格,那么它是怎么判断的?认为空格也是字符串String username3 = " ";System.out.println(StringUtils.isEmpty(username3)); //falseString username4 = "路飞";System.out.println(StringUtils.isEmpty(username4)); //falseString username5 = "....";System.out.println(StringUtils.isEmpty(username5)); //false}
1.2.可以判断Integer类型的数据是否为空
@Testpublic void test5(){Integer one=2;Integer two=null;if (StringUtils.isEmpty(one)){System.out.println("one是空的");}else {System.out.println("one不是空的");}if (StringUtils.isEmpty(two)){System.out.println("two是空的");}else {System.out.println("two不是空的");}}