A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

© Over_Mstuang 中级黑马   /  2015-8-14 01:30  /  309 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

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);
}
}

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马