java字符数组与字符串相互转换
1.字符串转化为字符数组
public class Hello { public static void main(String args[]){ Scanner input = new Scanner(System.in); String str="abc"; char[] c=str.toCharArray(); for(int i=0;i<c.length;i++) System.out.print(c[i]); } }
2.字符数组转化为字符串
public class Hello { public static void main(String args[]){ char[] cc={'a','b','c'}; String s=String.valueOf(cc); System.out.println(s); } }