Java – Create String from Char Array

To create a String from char array in Java, create a new String object with String() constructor and pass the char array as argument to the constructor.

In the following example, we will take a char array {'a', 'b', 'c', 'd'} and create a new string str from this char array.

Java Program

public class Example {
	public static void main(String[] args) {
		char arr[] = {'a', 'b', 'c', 'd'};
		String str = new String(arr);
		System.out.println("Resulting string is : " + str);
	}
}
ADVERTISEMENT

Output

Resulting string is : abcd

Conclusion

In this Java Tutorial, we learned how to create a String from Char array.