Groovy String类型null和empty("")判断
public static void main(String[] args) {
def a = ""
def b = null
if (a?.trim()){ //a为null/"" a?.trim()表达式为false
println("not empty or null")
}
else {
def c = a?.trim()
println("empty or null")
}
}
欢迎关注Java流水账公众号
public static void main(String[] args) {
def a = ""
def b = null
if (a?.trim()){ //a为null/"" a?.trim()表达式为false
println("not empty or null")
}
else {
def c = a?.trim()
println("empty or null")
}
}