In this post, we will discuss how can we convert a char array to a string in Java?

Method 1: using String.valueOf()

To convert a character array into a string in Java we can use the valueOf() method of the String class.

Using toString() method will not give any compilation but will definitely result in garbage value, so it is recommended to not use it.


Method 2: using String Constructor

The String class has an overloaded parametrized constructor that takes a char array as an argument and thus internally converts it to a string.


There are some other methods also to convert a char array to a string, for example, using StringBuilder but it is not so efficient in terms of the number of codes.

If you have any doubts or suggestion then please comment below.

Leave a Reply

three × one =