Languages
[Edit]
EN

Java - convert list to string

0 points
Created by:
Alicia-Lambert
520

In this article, we would like to show you how to convert List to String in Java.

Quick solution:

List<String> letters = Arrays.asList("A", "B", "C");
String result = String.join("", letters);

System.out.println(result);  // ABC

 

Practical example

In this example, we join items from fruits List using String join() method with empty string ("") as a separator.

import java.util.Arrays;
import java.util.List;

public class Example {

    public static void main(String[] args) {
        List<String> letters = Arrays.asList("A", "B", "C");

        String result = String.join("", letters);

        System.out.println("List: " + letters);   // [A, B, C]
        System.out.println("String: " + result);  // ABC
    }
}

Output:

List: [A, B, C]
String: ABC
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Cross technology - convert list to string

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join