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")
}
}
posted @ 2018-07-11 14:32  安琪拉的博客(公众号)  阅读(3648)  评论(0编辑  收藏  举报