• <tfoot id='gB4i6'></tfoot>

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

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

      1. <legend id='gB4i6'><style id='gB4i6'><dir id='gB4i6'><q id='gB4i6'></q></dir></style></legend>
          <bdo id='gB4i6'></bdo><ul id='gB4i6'></ul>
      2. 使用 + 连接字符串总是一个坏主意吗

        Is it always a bad idea to use + to concatenate strings(使用 + 连接字符串总是一个坏主意吗)
        <legend id='Y5Gi9'><style id='Y5Gi9'><dir id='Y5Gi9'><q id='Y5Gi9'></q></dir></style></legend>
        <i id='Y5Gi9'><tr id='Y5Gi9'><dt id='Y5Gi9'><q id='Y5Gi9'><span id='Y5Gi9'><b id='Y5Gi9'><form id='Y5Gi9'><ins id='Y5Gi9'></ins><ul id='Y5Gi9'></ul><sub id='Y5Gi9'></sub></form><legend id='Y5Gi9'></legend><bdo id='Y5Gi9'><pre id='Y5Gi9'><center id='Y5Gi9'></center></pre></bdo></b><th id='Y5Gi9'></th></span></q></dt></tr></i><div id='Y5Gi9'><tfoot id='Y5Gi9'></tfoot><dl id='Y5Gi9'><fieldset id='Y5Gi9'></fieldset></dl></div>

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

                  <bdo id='Y5Gi9'></bdo><ul id='Y5Gi9'></ul>
                    <tbody id='Y5Gi9'></tbody>
                  <tfoot id='Y5Gi9'></tfoot>
                • 本文介绍了使用 + 连接字符串总是一个坏主意吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的代码如下:

                  String s = "";
                  for (My my : myList) {
                      s += my.getX();
                  }
                  

                  当我这样做时,Findbugs 总是报告错误.

                  Findbugs always reports error when I do this.

                  推荐答案

                  如果你手动连接,我会使用 +

                  I would use + if you are manually concatenating,

                  String word = "Hello";
                  word += " World!";
                  

                  但是,如果您要迭代和连接,我建议 StringBuilder,

                  However, if you are iterating and concatenating I would suggest StringBuilder,

                  StringBuilder sb = new StringBuilder();
                  for (My my : myList) {
                      sb.append(my.getX());
                  }
                  

                  这篇关于使用 + 连接字符串总是一个坏主意吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                        <bdo id='91gkJ'></bdo><ul id='91gkJ'></ul>

                          <tfoot id='91gkJ'></tfoot>
                            <tbody id='91gkJ'></tbody>

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

                            <small id='91gkJ'></small><noframes id='91gkJ'>

                          2. <legend id='91gkJ'><style id='91gkJ'><dir id='91gkJ'><q id='91gkJ'></q></dir></style></legend>