Hello readers! In this tutorial, we feature an example on how to convert a Char Array to String in Java. We will learn different ways of this conversion. Meanwhile, you can also check the String to Char Array Example.
Java programming offers possible ways to convert a character array (
char ) to String. A new String is allocated that represents the sequence of characters contained in the char array. There are three ways to perform this conversion in Java i.e.
- Using String object
- Using a StringBuilder object
To start with the captioned tutorial, we are hoping that users at present have their preferred Ide installed on their machines. For easy usage, I am using Eclipse Ide on a Windows operating system.
2. Char Array to String Java Example
In this example, we’ll demonstrate the above-mentioned ways to perform the character array to String conversion. For a better understanding, developers can execute the below code in Eclipse Ide.
2.1 Char Array to String Java Conversion
Let us understand this with the help of a simple code snippet.
If everything goes well, the following output will be printed in the Ide console.
That is all for this tutorial and I hope the article served you whatever you were looking for. Happy Learning and do not forget to share!
In this tutorial, we learned how to convert a character array to a String. Developers can download the sample application as an Eclipse project in the Downloads section.
This was an example of how to convert a char array to a String in Java.
You can download the full source code of this example here: Char Array to String Java Example