Java: convert List to a String

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

    Try this:

    java.util.Arrays.toString(anArray).replaceAll(", ", ",")
                    .replaceFirst("^\\[","").replaceFirst("\\]$","");
    

提交回复
热议问题