基本数据类型转换为字符串类型:
1、将基本数据类型与空字符串(" ")连接(+)即可获得其所对应的字符串
2、调用String 类中的valueOf()方法返回相应字符串
3、使用包装类的toString()方法
int i = 123; String s1 = i + ""; String s2 = String.valueOf(i); String s3 = Integer.toString(i);
字符串类型转换为基本数据类型:
1、调用基本数据类型对应的包装类中的方法parseXXX(String)
2、对应包装类型的valueOf(String)
String str = "123"; int str1 = Integer.parseInt(str); int str2 = Integer.valueOf(str);
原文:https://www.cnblogs.com/mlllily/p/13809258.html