JAVA API文档对于intValue()、parseInt()、valueOf()的介绍:



详解见代码
- package JAVA_API;
-
- public class Test {
- public static void main(String[] args) {
- Integer i=new Integer("10");
- //将包装类型的对象转换成基本数据类型(非静态方法,需创建对象)
- int x=i.intValue();
- System.out.println(x);
- //将String类型转换成基本数据类型(静态方法,可直接调用类)
- int c=Integer.parseInt("1234");
- System.out.println(c);
- //将给定参数转换为包装类型(静态方法,可直接调用类)
- Integer a=Integer.valueOf("8888");
- System.out.println(a.intValue());
- }
- }