WrapperClass

* 测试包装类的基本用法;
* 包装类就是把基本属性也变成对象,方便有时候用;
* 八种基本属性,其他类型类似于integer,除了int-integer和char-character;其他都是原样;
* @author xu-saozhu
*实际上Java lang包里有Wrapper包装类,里面有个抽象类number,八种基本属性就是根据这个number类来重写得到的。

 1 public class WrapperClass {
 2     public static void main(String[]args){
 3         Integer i=new Integer(1000);//这样把1000包装成一个对象了
 4         System.out.println(Integer.MAX_VALUE);//最大的数
 5         System.out.println(Integer.toHexString(i));//把1000转换为16进制
 6         Integer i2=Integer.parseInt("234");//把字符串转换为数
 7         System.out.println(i2+10);// 应该输出244
 8         Integer i3=new Integer("233");//也是直接转换为数字
 9         String str=123+"";//数字转换成字符串;
10     }
11 }
原文地址:https://www.cnblogs.com/myErebos/p/8588236.html