Convert char array to string in Java
Description
The following code shows how to convert char array to string.
Example
/*from w w w. ja va2s . c om*/
public class Main {
public static void main(String[] args) {
char[] data = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
String text = String.valueOf(data);
System.out.println(text);
text = String.copyValueOf(data, 3, 5);
System.out.println(text);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »