Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Transform a list of strings into 1 string with new lines between successive elements of the list in

Mouna Hammoudi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 28, 2023

I have the following code in which `componentList` is a list of strings

String text = "The super feature " + issue + " will be split into " + componentSize + " features, one for each component:\n"

text = text + componentList.toString() + "\n";

I am getting the following output:

The super feature SF-797 will be split into 10 features, one for each component:
[WF-ActiveTransfer ===> WILL BE GENERATED, WF-Central Security Library ===> WILL BE GENERATED, WF-Integration Server ===> WILL BE GENERATED, WF-OSGi ===> WILL BE GENERATED, WF-Service Development ===> WILL BE GENERATED, WF-webMethods.io Integration Connectors ===> WILL BE GENERATED, WF-webMethods.io MFT ===> WILL BE GENERATED, WF-WebReader ===> WILL BE GENERATED, YF-ARIS Connect ===> WILL BE GENERATED, YF-PPM ===> WILL BE GENERATED]

I would like to transform this output into the following with a new line generated between each pair of successive elements of the list:

I don't want to use a loop and keep looping as this would not be efficient.

The super feature SF-797 will be split into 10 features, one for each component:
WF-ActiveTransfer ===> WILL BE GENERATED
WF-Central Security Library ===> WILL BE GENERATED
WF-Integration Server ===> WILL BE GENERATED
WF-OSGi ===> WILL BE GENERATED
WF-Service Development ===> WILL BE GENERATED
WF-webMethods.io Integration Connectors ===> WILL BE GENERATED
WF-webMethods.io MFT ===> WILL BE GENERATED
WF-WebReader ===> WILL BE GENERATED
YF-ARIS Connect ===> WILL BE GENERATED,
YF-PPM ===> WILL BE GENERATED

1 answer

1 accepted

1 vote
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
September 29, 2023

Hi @Mouna Hammoudi

Have you tried using:-

componentList.join('\n')

 This will return all the list content as a multi-line String.

I hope this helps to answer your question. :-)

Thank you and Kind regards,

Ram

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
October 3, 2023

Hi @Mouna Hammoudi

Has your question been answered?

If yes can you please accept the answer.

Thank you and Kind regards,

Ram

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events