Java: convert List to a String

前端 未结 22 2860
日久生厌
日久生厌 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:42

    You can use the apache commons library which has a StringUtils class and a join method.

    Check this link: https://commons.apache.org/proper/commons-lang/javadocs/api.2.0/org/apache/commons/lang/StringUtils.html

    Note that the link above may become obsolete over time, in which case you can just search the web for "apache commons StringUtils", which should allow you to find the latest reference.

    (referenced from this thread) Java equivalents of C# String.Format() and String.Join()

提交回复
热议问题