STRCON.LOOP

Using string concatenation in a loop wastes time and memory. Use StringBuffer instead.

Example 1

Copy
     public String test1(int n, String x) {
      String res = "";
      for (int i = 0; i < n; i++) {
        res+=x;
      }
      return res;
    }
    // fixed code
    public String test2(int n, String x) {
      StringBuffer res = new StringBuffer();
      for (int i = 0; i < n; i++) {
        res.append(x);
      }
      return res.toString();
    }

STRCON.LOOP is reported for line 12: Using append for string 'res' in a loop