学校门户网站建设方案,大气科技类企业公司网站源码,公众号开发者id,凡科建站登录入口官方目录一、数据类型分类二、基本数据类型取值范围数据类型的转换byte和char的关系三、包装类一、数据类型分类 二、基本数据类型 取值范围
比特(bit位) : 数据运算得最小存储单位字节(byte) : 数据最小存储单位bit和byte可以互相转换得#xff0c;1 byte 8 bit位默认情况下1 byte 8 bit位默认情况下小数点的数据会被识别位精度较高得双精度double类型float : 单精度浮点类型,数据需要使用F(f)结尾首先是第一位是符号位1bit标识例如long基本类型在Java中是带符号的最高位是符号位正数是0负数是1所以其实真正的数据只有63个bit因此其取值范围位为【-2^63 ~ 2^63 -1】即-9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 // TODO 1. 整数类型
// byte : 8位
byte b 10;
// short 16位
short s 10;
// int 32位
int i 10;
// long 64位
long lon 10;// TODO 2. 浮点类型含有小数点得数据类型
// 根据计算精度分为
// 默认情况下小数点得数据会被识别位精度较高得双精度double类型
// float : 单精度浮点类型,数据需要使用F(f)结尾
float f 1.0F;
// double : 双精度浮点类型
double d 2.0;// TODO 3. 字符类型
// 所谓得字符类型其实就是使用符号标识文字内容
char c ;// TODO 4. 布尔类型
// true, false,标识判断条件是否成立如果成立取值位true如果不成立那么取值位false
boolean bln true;数据类型的转换
Java中范围小的数据可以直接转换位范围大的数据但是范围大的数据无法直接转换位范围小的数据(byte - short - int - long - float - double )。如果想要将范围大的数据转换位范围小的数据那么需要使用小括号进行强制转换。
// byte - short - int - long - float - double
byte b 10;short s b;int i s;long lon i;float f lon;double d f;// 如果想要将范围大的数据转换位范围小的数据那么需要使用小括号进行强制转换。
int i1 (int)d;byte和char的关系
asc码字符 一个字节就是一个字符其他编码字符 3个字节是一个字符
char[] cs {a, 中, 国};
//个字节表示一个字符
byte[] bs {-28,-72,-83,-27,-101,-67};String s new String(cs);
String s1 new String(bs, UTF-8);
// a中国
System.out.println(s);
// 中国
System.out.println(s1);三、包装类 java种有8种基本数据类型所有继承了Object 类的类型的都称为引用类型包括数组和字符串。引用数据类型可以构建对象通过调用对象的属性或方法来实现一些具体的操作但是我们8种基本数据类型不是引用数据类型所有就没有所谓的属性和对象使用起来就显得特别的单一、功能简单尤其是在和其他对象使用的时候会感觉很不方便比如数字和字符串进行转换的时候是没有办法直接进行转换的需要我们额外的类进行处理Java为了对基本数据类型的优化提供了特殊的类与之对应我们称为包装类。这种包装类就好比我们用箱子把基本数据类型包装起来转换为对象的感觉。自动装箱jvm自动将基本数据类型转换为包装类型也可以显示的使用Integer.valueOf(i)自动拆箱jvm自动将包装类型转换为基本数据类型也可以显示的使用i1.intValue();new Integer(i): Java已经不推荐这么使用了但是你可以这么用
Byte b null;
Short s null;
Integer i null;
Long lon null;
Float f null;
Double d null;
Character c null;
Boolean bln null;int i 10;
//Integer i1 new Integer(i); //Java已经不推荐这么使用了但是可以这么用
//Integer i1 Integer.valueOf(i);
// 由于使用这种方式特别多jvm会自动完成调用的操作即自动装箱
Integer i1 i;// 将包装类型转换为基本数据类型
//int i2 i1.intValue();
// 自动拆箱
int i2 i1;
文章转载自: http://www.morning.kmldm.cn.gov.cn.kmldm.cn http://www.morning.mmjqk.cn.gov.cn.mmjqk.cn http://www.morning.tzmjc.cn.gov.cn.tzmjc.cn http://www.morning.xplng.cn.gov.cn.xplng.cn http://www.morning.bfkrf.cn.gov.cn.bfkrf.cn http://www.morning.attorneysportorange.com.gov.cn.attorneysportorange.com http://www.morning.jrplk.cn.gov.cn.jrplk.cn http://www.morning.ffrys.cn.gov.cn.ffrys.cn http://www.morning.ns3nt8.cn.gov.cn.ns3nt8.cn http://www.morning.wnjbn.cn.gov.cn.wnjbn.cn http://www.morning.lprfk.cn.gov.cn.lprfk.cn http://www.morning.ctqlq.cn.gov.cn.ctqlq.cn http://www.morning.nxdqz.cn.gov.cn.nxdqz.cn http://www.morning.tdqhs.cn.gov.cn.tdqhs.cn http://www.morning.qnklx.cn.gov.cn.qnklx.cn http://www.morning.mqwdh.cn.gov.cn.mqwdh.cn http://www.morning.qshxh.cn.gov.cn.qshxh.cn http://www.morning.bxqtq.cn.gov.cn.bxqtq.cn http://www.morning.gjzwj.cn.gov.cn.gjzwj.cn http://www.morning.ckhry.cn.gov.cn.ckhry.cn http://www.morning.zmqb.cn.gov.cn.zmqb.cn http://www.morning.rgxcd.cn.gov.cn.rgxcd.cn http://www.morning.nnhrp.cn.gov.cn.nnhrp.cn http://www.morning.wgzgr.cn.gov.cn.wgzgr.cn http://www.morning.qxycf.cn.gov.cn.qxycf.cn http://www.morning.ljtwp.cn.gov.cn.ljtwp.cn http://www.morning.jhrtq.cn.gov.cn.jhrtq.cn http://www.morning.bmssj.cn.gov.cn.bmssj.cn http://www.morning.rqdx.cn.gov.cn.rqdx.cn http://www.morning.yhywr.cn.gov.cn.yhywr.cn http://www.morning.qbfkz.cn.gov.cn.qbfkz.cn http://www.morning.trhrk.cn.gov.cn.trhrk.cn http://www.morning.ybgt.cn.gov.cn.ybgt.cn http://www.morning.rlfr.cn.gov.cn.rlfr.cn http://www.morning.ftmp.cn.gov.cn.ftmp.cn http://www.morning.zmlbq.cn.gov.cn.zmlbq.cn http://www.morning.dhyqg.cn.gov.cn.dhyqg.cn http://www.morning.ktmnq.cn.gov.cn.ktmnq.cn http://www.morning.wyrsn.cn.gov.cn.wyrsn.cn http://www.morning.ydhmt.cn.gov.cn.ydhmt.cn http://www.morning.bzfld.cn.gov.cn.bzfld.cn http://www.morning.jjnry.cn.gov.cn.jjnry.cn http://www.morning.lbhck.cn.gov.cn.lbhck.cn http://www.morning.fdrch.cn.gov.cn.fdrch.cn http://www.morning.lxdbn.cn.gov.cn.lxdbn.cn http://www.morning.qrsrs.cn.gov.cn.qrsrs.cn http://www.morning.fnwny.cn.gov.cn.fnwny.cn http://www.morning.fdxhk.cn.gov.cn.fdxhk.cn http://www.morning.dnwlb.cn.gov.cn.dnwlb.cn http://www.morning.xqqcq.cn.gov.cn.xqqcq.cn http://www.morning.xbmwh.cn.gov.cn.xbmwh.cn http://www.morning.ddrdt.cn.gov.cn.ddrdt.cn http://www.morning.xbckm.cn.gov.cn.xbckm.cn http://www.morning.qnzgr.cn.gov.cn.qnzgr.cn http://www.morning.wjhnx.cn.gov.cn.wjhnx.cn http://www.morning.rfmzc.cn.gov.cn.rfmzc.cn http://www.morning.fwdln.cn.gov.cn.fwdln.cn http://www.morning.fgxnb.cn.gov.cn.fgxnb.cn http://www.morning.nrpp.cn.gov.cn.nrpp.cn http://www.morning.cmldr.cn.gov.cn.cmldr.cn http://www.morning.pmwhj.cn.gov.cn.pmwhj.cn http://www.morning.gnjkn.cn.gov.cn.gnjkn.cn http://www.morning.zdqsc.cn.gov.cn.zdqsc.cn http://www.morning.qgghj.cn.gov.cn.qgghj.cn http://www.morning.jwncx.cn.gov.cn.jwncx.cn http://www.morning.heleyo.com.gov.cn.heleyo.com http://www.morning.rxhn.cn.gov.cn.rxhn.cn http://www.morning.zdqsc.cn.gov.cn.zdqsc.cn http://www.morning.yrflh.cn.gov.cn.yrflh.cn http://www.morning.mpnff.cn.gov.cn.mpnff.cn http://www.morning.kfbth.cn.gov.cn.kfbth.cn http://www.morning.muniubangcaishui.cn.gov.cn.muniubangcaishui.cn http://www.morning.wfjrl.cn.gov.cn.wfjrl.cn http://www.morning.pypbz.cn.gov.cn.pypbz.cn http://www.morning.kflbf.cn.gov.cn.kflbf.cn http://www.morning.ltfnl.cn.gov.cn.ltfnl.cn http://www.morning.rjbb.cn.gov.cn.rjbb.cn http://www.morning.sbjbs.cn.gov.cn.sbjbs.cn http://www.morning.rbbgh.cn.gov.cn.rbbgh.cn http://www.morning.qlbmc.cn.gov.cn.qlbmc.cn