通过以下代码可理解:
public class Test3 {
public static void main(String[] args) {
//将数字100转化为Integer包装类型
Integer i = new Integer(100);
System.out.println(i);
//将String类型的数字转化为Integer包装类型
Integer s = new Integer("100");
System.out.println(s);
//将数字100转化为Double包装类型
Double d = new Double(123);
System.out.println(d);
//将String类型的数字转化为Double包装类型
Double t = new Double("123");
System.out.println(t);
//通过访问包装类的常量可以获取最大值或者最小值
System.out.println("int的最大值" + Integer.MAX_VALUE);
System.out.println("int的最小值" + Integer.MIN_VALUE);
System.out.println("byte的最大值" + Byte.MAX_VALUE);
System.out.println("byte的最小值" + Byte.MAX_VALUE);
int i3 = Integer.parseInt("123");
System.out.println(i3);
}
}
输出结果为: