kotlin字符串判空
Given a string, we have to check whether it is an empty, blank or NULL string.
给定一个字符串,我们必须检查它是否为空,空白或NULL字符串。
Example:
例:
Input:
str = ""
Output:
True
用于在Kotlin中检查Empty,Blank或NULL字符串的程序 (Program to check for Empty, Blank or NULL string in Kotlin)
package com.includehelp.basic
//Main Function, entry Point of Program
fun main(args: Array<String>) {
///Nullable String
val s1: String?=null
//Empty String
val s2: String=""
//Blank String, Contained only white spaces
val s3=" "
println("String s1 is isNullOrEmpty : ${s1.isNullOrEmpty()}")
println("String s2 is isEmpty : ${s2.isEmpty()}")
println("String s3 is isBlank : ${s3.isBlank()}")
}
Output
输出量
String s1 is isNullOrEmpty : true
String s2 is isEmpty : true
String s3 is isBlank : true
翻译自: https://www.includehelp.com/kotlin/check-for-empty-blank-or-null-string.aspx
kotlin字符串判空