包装类的使用
-
基本数据类型 ------------- > 包装类:调用包装类的构造器
int i=10; Integer integer = new Integer(i); System.out.println(integer.toString()); Integer integer1=new Integer("123"); System.out.println(integer1.toString()); Boolean aBoolean = new Boolean(true); Boolean aBoolean2 = new Boolean("true"); System.out.println(aBoolean.toString()); System.out.println(aBoolean2.toString());
-
包装类 --------------> 基本数据类型:调用包装类的xxxValue()
Integer integer = new Integer(12); int i = integer.intValue(); System.out.println(i); Float aFloat = new Float(11.3); float v = aFloat.floatValue(); System.out.println(v);