This post will discuss how to convert a list of Characters to string in Java.

1. Naive solution

A simple solution is to iterate through the list and create a new string with the help of the StringBuilder class, as shown below:

Download  Run Code

2. Using Java 8

In Java 8, we can make use of Stream with Collectors, as shown below:

Download  Run Code

3. Using Guava Library

We can use Guava’s Joiner class to join pieces of text specified as an array and returns the results as a String. We can use this class, as shown below:

Download Code

4. Using Apache Commons Lang

Like Guava, Apache Commons Lang StringUtils class offers a join() method that can join the specified array elements into a single string.

Download Code

5. Using List.toString() method

(Not recommended)

We can get a string representation of the list elements, which are enclosed in square brackets ("[]"), and all adjacent elements are separated by a comma, followed by a space ", ". The idea is to get rid of the square brackets using the substring() method and comma + space by using the replaceAll() method.

Download  Run Code

That’s all about converting List of Character to Java String.