I want check value of my EditText in 和roid so I saw two function for my String value :

user.isNullOrBlank()

user.isNullOrEmpty()

what is difference between them?

推荐答案

isNullOrBlank()将空格考虑在内:

fun main() {
  val thisIsBlank = "   "

  println(thisIsBlank.isNullOrEmpty())
  println(thisIsBlank.isNullOrBlank())
}

这张照片是:

false
true

because thisIsBlank is not empty, but it is blank.

Kotlin相关问答推荐

如何在 Big Data 中使用Inc过滤器?

测试Compose Multiplatform UI时,为另一个文件设置ComposeRule()

映射中列表类型的Kotlin可空接收器?

可选的.在kotlin中不使用泛型参数

我需要后台工作才能使用卡夫卡的消息吗?

在 Kotlin 中将 Array 转换为 IntArray 时丢失值

为什么使用 return instance ?: synchronized(this) { instance ?: PreferenceParameterState(context) } 时无法获得单例?

可以在没有导入声明的情况下调用 Kotlin 扩展函数吗?

使用事务时未调用 Kafka ConsumerInterceptor onCommit

kotest 更改环境变量

类型是什么意

Foo::class.java 和 Foo::javaClass 有什么区别?

runOnUiThread 没有调用

Kotlin中的下划线名称是为什么保留的?

Kotlin 的 Double.toInt() 中使用了哪种方法,舍入还是截断?

Spring Boot:更改属性占位符符号

ObjectAnimator.ofFloat 不能直接在kotlin中取Int作为参数

如何在 Gradle Kotlin DSL 中使用来自 gradle.properties 的插件版本?

Kotlin内联属性的用例是什么?

var str:String是可变的还是不可变的?