How to convert a char array into a string in Java

 Posted On  | Yashwant Chavan 

In this tutorial you will learn how to convert a char array into a string using Java API's

Char Array to String

Below Java program, convert a char array to a String value.

java.lang.String.String(char[] value) - Allocates a new String so that it represents the sequence of characters currently contained in the character array argument.

String java.lang.String.valueOf(char[] data) - Returns the string representation of the char array argument.


public class CharArrayToString {
    public static void main(String args[]) {

        char[] chars = {'h','e','l','l','o'};
        String hello = new String(chars);

        String helloValueOf = String.valueOf(chars);



Promote your Blog, Website, or services on, My paypal id:

Payment will be accepted through paypal only.

© 2017

 |  Find us on Google+ |  Rss Feed

Loaded in 0.0354 seconds.