Languages
[Edit]
EN

Java - convert list to string

0 points
Created by:
Alicia-Lambert
340

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
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