• <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. 使用 + 连接字符串总是一个坏主意吗

        时间:2024-08-25
        <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());
                  }
                  

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

                  上一篇:如果您有 ISO 国家代码 `US`、`FR`,如何获得区域设置代码(`Locale.US`、`Locale.FRANC 下一篇:无论当前的默认语言环境如何,如何获取默认 ResourceBundle

                  相关文章

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

                  1. <tfoot id='91gkJ'></tfoot>
                    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>