Char Array to String Java

Char Array to String Java

Sometimes, it may be required in coding to convert array to string. The array may be in the form of characters or byte.

Two styles exist to convert array to string. One is using String constructor and the other using copyValueOf()() method.

Following example converts char array to string.

Char Array to String JavaOutput Screenshot on Char Array to String Java

In the above example all the characters are of the char array are converted into string. To convert a few characters of char array and also to convert byte array elements see Array to String.

Leave a Reply

Your email address will not be published. Required fields are marked *