• <bdo id='LZ5Jj'></bdo><ul id='LZ5Jj'></ul>
      <tfoot id='LZ5Jj'></tfoot>

      <small id='LZ5Jj'></small><noframes id='LZ5Jj'>

    1. <i id='LZ5Jj'><tr id='LZ5Jj'><dt id='LZ5Jj'><q id='LZ5Jj'><span id='LZ5Jj'><b id='LZ5Jj'><form id='LZ5Jj'><ins id='LZ5Jj'></ins><ul id='LZ5Jj'></ul><sub id='LZ5Jj'></sub></form><legend id='LZ5Jj'></legend><bdo id='LZ5Jj'><pre id='LZ5Jj'><center id='LZ5Jj'></center></pre></bdo></b><th id='LZ5Jj'></th></span></q></dt></tr></i><div id='LZ5Jj'><tfoot id='LZ5Jj'></tfoot><dl id='LZ5Jj'><fieldset id='LZ5Jj'></fieldset></dl></div>
    2. <legend id='LZ5Jj'><style id='LZ5Jj'><dir id='LZ5Jj'><q id='LZ5Jj'></q></dir></style></legend>

      1. 在java中将列表转换为逗号分隔字符串的最佳方法

        时间:2023-10-13

          <bdo id='u129U'></bdo><ul id='u129U'></ul>
        • <small id='u129U'></small><noframes id='u129U'>

            <tbody id='u129U'></tbody>

          1. <tfoot id='u129U'></tfoot>
              • <legend id='u129U'><style id='u129U'><dir id='u129U'><q id='u129U'></q></dir></style></legend>
                <i id='u129U'><tr id='u129U'><dt id='u129U'><q id='u129U'><span id='u129U'><b id='u129U'><form id='u129U'><ins id='u129U'></ins><ul id='u129U'></ul><sub id='u129U'></sub></form><legend id='u129U'></legend><bdo id='u129U'><pre id='u129U'><center id='u129U'></center></pre></bdo></b><th id='u129U'></th></span></q></dt></tr></i><div id='u129U'><tfoot id='u129U'></tfoot><dl id='u129U'><fieldset id='u129U'></fieldset></dl></div>

                • 本文介绍了在java中将列表转换为逗号分隔字符串的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有 Set;结果 &想将其转换为逗号分隔的字符串.我的方法如下所示,但也在寻找其他意见.

                  I have Set<String> result & would like to convert it to comma separated string. My approach would be as shown below, but looking for other opinion as well.

                  List<String> slist = new ArrayList<String> (result);
                  StringBuilder rString = new StringBuilder();
                  
                  Separator sep = new Separator(", ");
                  //String sep = ", ";
                  for (String each : slist) {
                      rString.append(sep).append(each);
                  }
                  
                  return rString;
                  

                  推荐答案

                  Java 8 起:

                  String.join(",", slist);
                  

                  来自 Apache Commons 库:

                  From Apache Commons library:

                  import org.apache.commons.lang3.StringUtils
                  

                  用途:

                  StringUtils.join(slist, ',');
                  

                  另一个类似的问答这里

                  这篇关于在java中将列表转换为逗号分隔字符串的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Android Parcelable - 使用通用数据类型读取/写入数据到 Parcel 下一篇:基于添加重复值的HashSet vs TreeSet vs LinkedHashSet

                  相关文章

                  • <bdo id='Smlch'></bdo><ul id='Smlch'></ul>
                • <i id='Smlch'><tr id='Smlch'><dt id='Smlch'><q id='Smlch'><span id='Smlch'><b id='Smlch'><form id='Smlch'><ins id='Smlch'></ins><ul id='Smlch'></ul><sub id='Smlch'></sub></form><legend id='Smlch'></legend><bdo id='Smlch'><pre id='Smlch'><center id='Smlch'></center></pre></bdo></b><th id='Smlch'></th></span></q></dt></tr></i><div id='Smlch'><tfoot id='Smlch'></tfoot><dl id='Smlch'><fieldset id='Smlch'></fieldset></dl></div>

                  <small id='Smlch'></small><noframes id='Smlch'>

                  <legend id='Smlch'><style id='Smlch'><dir id='Smlch'><q id='Smlch'></q></dir></style></legend>
                  1. <tfoot id='Smlch'></tfoot>