Convert List of String> to List of Object java

InJava, we have a lot of ways to convert List of String object to String object with a delimiter between the elements in List object. In this tutorial, I will share with you all some ways as below:

The first one, we will use StringBuilder object in Java.

We will read all elements in the List, one by one and useStringBuilderto add the delimiter among all elements. Note that, with the first element, we will not add the delimiter!

In detail, the method can be written as below:

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
public static String join[List list, char delimiter] {
StringBuilder sb = new StringBuilder[];
for [int i = 0; i

Chủ Đề