首页 > 移动平台 > 详细

WrapperClass

时间:2018-03-17 11:43:41      阅读:192      评论:0      收藏:0      [点我收藏+]

* 测试包装类的基本用法;
* 包装类就是把基本属性也变成对象,方便有时候用;
* 八种基本属性,其他类型类似于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 }

 

WrapperClass

原文:https://www.cnblogs.com/myErebos/p/8588236.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!