Java: convert List to a String

前端 未结 22 2633
日久生厌
日久生厌 2020-11-22 01:03

JavaScript has Array.join()

js>[\"Bill\",\"Bob\",\"Steve\"].join(\" and \")
Bill and Bob and Steve

Does Java have anything

22条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 01:38

    You might want to try Apache Commons StringUtils join method:

    http://commons.apache.org/lang/api/org/apache/commons/lang/StringUtils.html#join(java.util.Iterator, java.lang.String)

    I've found that Apache StringUtils picks up jdk's slack ;-)

提交回复
热议问题