1char[] a = {'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'};
2String str = new String(a);
1// java convert array of char to string
2public class CharArrayToString
3{
4 public static void main(String[] args)
5 {
6 char[] charArray = new char[]{'F','l','o','w','e','r','B','r','a','c','k','e','t','s'};
7 String str = new String(charArray);
8 System.out.println(str);
9 }
10}
1 final char[] charArray = { 'g','e','e','k','s','f','o','r','g','e','e','k','s' };
2 String string = new String(charArray);
3
4 System.out.println(string);
5
6 // -> "geeksforgeeks"
1
2 // Method 1: Using String object
3 char[] ch = {'g', 'o', 'o', 'd', ' ', 'm', 'o', 'r', 'n', 'i', 'n', 'g'};
4 String str = new String(ch);
5 System.out.println(str);
6