您现在的位置是:首页 > 文章详情

Java 面向对象 之 基本数据 包装类

日期:2018-08-28点击:301

http://www.verejava.com/?id=16992869307361

/** 知识点: 基本数据类型 对应的 包装类 1. 基本数据类型包括: 1. 数值类型 1.1 byte -> Byte 1.2 short -> Short 1.3 int -> Integer 1.4 long -> Long 1.5 float -> Float 1.6 double -> Double 2. 字符型 2.1 char -> Character 3. 布尔型 3.1 boolean -> Boolean 2. 包装类的应用 2.1 使基本数据类型也可以有引用类型 2.2 实现数据类型的转换功能 注意: 1. 在jdk 1.5 之后 基本数据类型和包装类型是可以相互赋值 */ public class WrapClass { public static void main(String[] args) { Byte a=1; byte b=10; a=b; System.out.println(a.byteValue()); System.out.println(Integer.valueOf(b)); //包装类的应用 主要是 数据类型的转换 //整型转 double 型 int c=100; Integer d=new Integer(c); System.out.println(d.doubleValue()); //整型转 long 型 System.out.println(d.longValue()); //整型转 字符串 String str=Integer.toString(d); System.out.println(str); //字符串转 整型 int e=Integer.parseInt(str); System.out.println(e); System.out.println(Integer.toBinaryString(e)); System.out.println(Integer.signum(e)); System.out.println(Integer.bitCount(e)); System.out.println(Integer.highestOneBit(e)); System.out.println(Integer.numberOfLeadingZeros(e)); } }

http://www.verejava.com/?id=16992869307361

原文链接:https://yq.aliyun.com/articles/630248
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章