public class Tests {
public static void main(String[] args) {
//String to 基本数据类型/包装类
int intNum=6;
String str="123";
intNum=Integer.parseInt(str);
//String转换为其他基本1类型格式同上:包装类.parseXXX(str);
//基本数据类型 to String
str=String.valueOf(intNum);
//其他类型转换同上
}
}
String --- char [ ]
public class Tests {
public static void main(String[] args) {
//String to char[]
String str="abc";
char[] chars=str.toCharArray();
//char[] to String
char[] cha=new char[]{'a','b','d'};
String st=new String(cha);
}
}
String --- byte [ ]
public class Tests {
public static void main(String[] args) {
// String to byte[]
String str="abc";
byte[] bytes=str.getBytes();
//byte[] to' String
String st=new String(bytes);
}
}



