kotlin_基础_空字符串 null or empty的判断

转载自: https://blog.csdn.net/vovo2000/article/details/106544264/

kotlin 字符串空值判断

在这里插入图片描述

1 isNotEmpty(str)等价于 str != null && str.length > 0
2 isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length > 0
3 同理
4 isEmpty 等价于 str == null || str.length == 0
5 isBlank  等价于 str == null || str.length == 0 || str.trim().length == 0
6 str.length > 0 && str.trim().length > 0  --->   str.length > 0

猜你喜欢

转载自blog.csdn.net/qq_42420293/article/details/122574968