Integer类的概念
java.lang.Integer 类是 int 类型的包装类,该类由 final 关键字修饰表示不能被继承.
该类重写了 equals( ) 方法,hashCode( ) 方法,to String( ) 方法.
常用的方法
- Integer( int value ) —根据参数指定的整数构造对象
- Integer( String s ) —根据参数指定的字符串构造对象
- int intValue( ) —用于获取调用对象中包装的整数数据并返回
- static Integer valueOf( int i ) —用于参数指定的整数得到 Integer 类型对象并返回
- static int parseInt( String s ) —用于将 String 类型转换为 int 类型
//1.实现Integer类型和int类型之间的转换
//Integer类型转换为int类型 ———— 拆箱机制
Integer it1 = new Integer(123);
int num = it1.intValue();
System.<