0

I have a problem with repeating a JSONArray. I can't repeat this string:

JSONArray jArray = new JSONArray(result);

                for (int i = 0; i < jArray.length(); i++) {
                    JSONObject json = jArray.getJSONObject(i);


                    String.repeat("firstname", 3);
                    Data=Data+""+  json.getString("firstname");
                    Data=Data+""+  json.getString("remark");
                    Data=Data+""+  json.getString("s_start");
                    Data=Data+""+  json.getString("department");

                }

How should I repeat this line?

Martijn Pieters
  • 963,270
  • 265
  • 3,804
  • 3,187
JCD
  • 135
  • 1
  • 14

2 Answers2

0

Use

String repeat = StringUtils.repeat(string_you_want_to_repeat, 3);
Kiran Benny Joseph
  • 6,607
  • 4
  • 37
  • 56
0

The answer is to use StringUtil.repeat("firstname",3) not String.repeat("firstname",3).

Here is the link for official documentation