• <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中将列表转换为逗号分隔字符串的最佳方法

        Best way to convert list to comma separated string in java(在java中将列表转换为逗号分隔字符串的最佳方法)

          <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中将列表转换为逗号分隔字符串的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Compiling C++ for the JVM(为 JVM 编译 C++)
                  Compile to java bytecode (without using Java)(编译成java字节码(不使用Java))
                  How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000 at compile time?(如何在编译时驱动 C#、C++ 或 Java 编译器计算 1+2+3+...+1000?)
                  Java ClassLoader: load same class twice(Java ClassLoader:两次加载相同的类)
                  How to debug .class files in ECLIPSE?(如何在 ECLIPSE 中调试 .class 文件?)
                  Java quot;The blank final field may not have been initializedquot; Anonymous Interface vs Lambda Expression(Java“可能尚未初始化空白的最终字段匿名接口与 Lambda 表达式)

                  • <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>
                        • <tfoot id='Smlch'></tfoot>
                            <tbody id='Smlch'></tbody>