Java – How to convert Char[] to String

In Java, we can use String.valueOf() to convert a char array to a String.

JavaSample1.java

package com.mkyong.markdown;

public class JavaSample1 {

    public static void main(String[] args) {

        char[] charArrays = new char[]{'1', '2', '3', 'A', 'B', 'C'};

        String str = new String(charArrays);
        System.out.println(str);    // 123ABC

        String str2 = String.valueOf(charArrays);
        System.out.println(str2);   // 123ABC

    }

}

Output


123ABC
123ABC

References

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Alfred
11 years ago

Can you give me some example java program how to store String character to char array.

mkyong
7 years ago
Reply to  Alfred

Try this – string.toCharArray()