Skip to content
Advertisement

convert java arraylist to array using for loop

I have viewed the many similar topics here, none have allowed me to resolve:

JavaScript

The many examples I have seen all create an array list by adding in the code, I already have the arrayList. I just need to modify it as an array string and not an arrayList so that I may properly format it as a JSON string with

JavaScript

Here is the entire bean :

JavaScript

I tried the following code, but it does not work.

JavaScript

Any suggestions greatly appreciated. Thanks

Advertisement

Answer

Use StringBuilder to build String :

JavaScript

Finally sb.toString() will be your desired String.

Advertisement