将字符数组转为字符串,或将字符串转为字符数组:char[] chars = {'a', 'b', 'c'};String asString = new String(chars);char[] back = asString.toCharArray();要检查 2 个字符数组是否相等:java.util.Arrays.equals(charArray1, charArray2)要检查 2 个字符串是否相等:string1.equals(string2);请注意,这不起作用:charArray1 == charArray2 // does not work. This checks if they are references to the same array, NOT if the contents are equalstring1 == string2 // also does not work; same reason.