I want check value of my EditText in android so I saw two function for my String value :
user.isNullOrBlank()
and
user.isNullOrEmpty()
what is difference between them?
empty refers to an empty string (a string with no characters, whose length is zero), whereas blank refers to a string that is either empty or consists entirely of whitespace characters.
To create an empty String in Kotlin, assign the variable with empty double quotes "" , or with String class constructor String() .
isNullOrBlank()
takes whitespace into account:
fun main() { val thisIsBlank = " " println(thisIsBlank.isNullOrEmpty()) println(thisIsBlank.isNullOrBlank()) }
This prints:
false true
because thisIsBlank
is not empty, but it is blank.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With