jnbt.net
当前位置:首页 >> jAvA把string转为ChAr >>

jAvA把string转为ChAr

public static void main(String[] args) { // TODO Auto-generated method stub String str = "aadfadsf"; char[] strChar = str.toCharArray(); for (char a:strChar) System.out.print(a+" "); }

String a="a"; char b=a.charAt(0); System.out.println(b); 输出结果为:a

public class Test { public static void main(String[] args){ String s="zhuanhuan"; int[] in=new int[s.length()]; for(int i=0;i

String s=“abcde”; char chs[]=s.toCharArray(); 就可以了

String str=“abcdef”; char[] ch=st.toCharArray(); char c = 'a'; String str = String.valueOf(c);

public class Test { public static void main(String[] args) { String str = "qwe"; for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); System.out.println(c); } char c[] = { 'a', 'b' }; String s = String.valueOf(c); S...

最简单的方法 public class Test { public static void main(String[] args){ String s="zhuanhuan"; int[] in=new int[s.length()]; for(int i=0;i

参考代码 import java.util.Arrays;public class StringChar {public static void main(String[] args) {//字符串--》字符String str1 = "风云";char c1 = str1.charAt(0);//风, 如果要得到云。那么charAt(1);System.out.println(c1);char[] cs...

把字符串转化为char数组: 例如: String str=“abcdef”; char[] ch=st.toCharArray(); 若要转化为单个char,可以从数组中取出来赋值给char

网站首页 | 网站地图
All rights reserved Powered by www.jnbt.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com