public static void main (String [] args) { // 1. Convert character array to string // (1) Convert char directly when constructing String [] array = new char [] {'a', 'b', 'c', 'd', 'e', 'f', 'g' }; String str = new String (array); System.out.println (str); // (2) call the provided by the String class Method of valueOf () String str2 = String.valueOf (array); System.out.println (str2); // 2. String is converted into a character array // (1) call toCharArray () of the method provided by the String class String msg = "i am a good boy!" ; char[] dest = msg.toCharArray(); System.out.println(Arrays.toString(dest)); }
Consloe: ↓
The above personal reference
https://blog.csdn.net/weixin_42153410/article/details/95494014