java字符数组char[]和字符串String之间的转换
觉得有用的话,欢迎一起讨论相互学习~Follow Me
使用String.valueOf()将字符数组转换成字符串
void (){
char[] s={'A','G','C','T'};
String st=String.valueOf(s);
System.out.println("This is : "+st);
}
>> This is : AGCT
使用.toCharArray()将字符串转换成字符数组
String st="AGCT";
char[] s=st.toCharArray();
for (int i=0;i<st.length();i++){
System.out.println("This s[i]"+i+s[i]);
}
This s[i]0A
This s[i]1G
This s[i]2C
This s[i]3T