Java数据类型中String、Integer、int相互间的转换

1.Integer转换成int的方法

1
2
3
Integer i; 
int k = i.intValue();
即Integer.intValue();

2.int转换成Integer

1
2
int i;
Integer it = new Integer(i);

3.String转换成int的方法

1
2
3
4
String str = "10";  
Integer it = new Interger(str);
int i = it.intValue();
即:int i = Integer.intValue(string);

4.int转换成String

1
2
3
4
int i;
(1)String s = String.valueOf(i);
(2)String s = Ingeger.toString(i);
(3)String s = "" + i;

5.String转换成Integer

1
2
String str = "10"
Integer it = Integer.valueOf(str);

6.Integer转换成String

1
2
Integer it;
String str = it.toString();

7.String转换成BigDecimal

1
BigDecimal bd = new BigDecimal(str);