StringBuilder append() and null values

后端 未结 8 927
借酒劲吻你
借酒劲吻你 2021-02-06 21:54

I have a list of Strings, and I want to concatenate them with spaces in between. So I\'m using StringBuilder. Now if any of the Strings ar

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-06 22:48

    You can use commons-lang's StringUtils#defaultString():

    sb.append("Value: ").append(StringUtils.defaultString(myVar));
    

提交回复
热议问题