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
  • 1,048,767
  • 296
  • 4,058
  • 3,343
JCD
  • 155
  • 1
  • 15

2 Answers2

0

Use

String repeat = StringUtils.repeat(string_you_want_to_repeat, 3);
Kiran Benny Joseph
  • 6,755
  • 4
  • 38
  • 57
0

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

Here is the link for official documentation