public class IntegerDemo2 {
public static void main(String[] args) {
// 把int类型变成Integer类型
int num = 100;
Integer i = new Integer(num);
System.out.println(i.toString());
// 把String类型变成Integer类型
String s = "100";
// String s = "100abc";
// NumberFormatException:数据格式化异常
Integer ii = new Integer(s);
System.out.println(ii);
}
}
|
|