converting char array to string in java code example

Example 1: java string to char array

String str = "example";
char[] ch = str.toCharArray();

Example 2: char array to string java

char[] a = {'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'};
String str = new String(a);

Example 3: java put a char array into a string

char[] arr = { 'p'," ",'q', 'r', 's' };
      String str = String.valueOf(arr);
      System.out.println(str);//"p qrs"

Example 4: char array to string

String string = String.valueOf(a);

Example 5: how to covert array into a char

String s="Welcome to Java Programming";
char arr[]=s.toCharArray();
for(int i=0;i
                    

Tags:

Misc Example