This tutorial demonstrate how to convert char array into a string. In the following code you will see the String.copyValueOf(charArray, 2, 5) return and creates new array of string and copies the specified characters into it and the String.valueOf(charArray) copy the content of character and convert it into string. The implementation is shown in below example.
|
public class CopyCharArrayToString { public static void main(String[] args) { char[] charArray = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' }; String str = String.valueOf(charArray); System.out.println(str); str = String.copyValueOf(charArray, 2, 5); System.out.println(str); } } |

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.