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")
}
}

猜你喜欢

转载自www.cnblogs.com/zhengwangzw/p/9294329.html
今日推荐