mshd.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 str=“abcdef”; char[] ch=st.toCharArray(); char c = 'a'; String str = String.valueOf(c);

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

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

参考代码 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...

参考代码 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...

public class Test { public static void main(String [] args) { char c = 'a'; System.out.println (c); String str = String.valueOf(c); System.out.println (str); } }

String string = "abcdsfkk;l";char[] chars = string.toCharArray();

代码 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[]...

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

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