因为自己总是记得不牢固,就写下来了。知识点:基本类型的包装类的装箱与拆箱
字符串转化为整数有两种方法:
//第一种方法
int i = Integer.parseInt(str);
//第二种方法
int i = Integer.valueOf(str);
//或者写成
int i = Integer.valueOf(str).intValue();
整数转化为字符串有三种方法:
//第一种方法
String s = String.valueOf(i);
//第二种方法
String s = Integer.toString(i);
//第三种方法
String s = ""+i;
注:byte,short,long等类型与字符串相互转化的方法大同小异,需要用到各自的包装类。