当前位置: 首页 > news >正文

网站设计建设维护与更新关键词在线查询

网站设计建设维护与更新,关键词在线查询,wordpress外贸建站主题,厦门市建设保障性住房局网站一、包装类 1.针对八种基本定义相应的引用类型一包装类 2.有了类的特点,就可以调用类中的方法。 黄色背景的表示父类是Number 二、包装类和基本数据的转换 演示包装类和基本数据类型的相互转换,这里以int和Integer演示。 1.jdk5前的手动装箱和拆箱方…

一、包装类

1.针对八种基本定义相应的引用类型一包装类

2.有了类的特点,就可以调用类中的方法。


黄色背景的表示父类是Number

 二、包装类和基本数据的转换

演示包装类和基本数据类型的相互转换,这里以int和Integer演示。

1.jdk5前的手动装箱和拆箱方式,箱: 基本类型-> 包装类型 反之,拆箱

2.jdk5以后(含jdk5)的自动装箱和拆箱方式

3.自动装箱底层调用的是valueOf方法,比如Integer.valueOf(),自动拆箱用的是Value方法,例如intValue();

public class Integer01 {public static void main(String[] args) {//演示int -- Integer的装箱和拆箱//手动装箱int n1 = 100;Integer integer = new Integer(n1);Integer integer1 = Integer.valueOf(n1);//手动拆箱//Integer -> intint i = integer.intValue();//jdk5以后就可以自动装箱自动拆箱了int n2 = 200;//自动装箱Integer integer2 = n2;//底层是使用了Interger.valueOf(n2),使用debug能看到走到valueOf;int n3 = integer2;//底层仍然是使用了方法integer.intValue()使用debug能看到走到intValue}
}

三、包装类的课堂练习

1.

第一段自动装箱

第二段常true执行冒号前的,动态绑定用Integer的toString方法

返回的为传入的值,所以输出1

不是1,三元运算符应该看做一个整体,所以会自动转换提升至最高的Double

所以输出的是1.0 

第三段同理删除线 1

2.

【疑问解决】在自动装箱中Integer赋予一个常量1,为什么会出现==判断true和flase的情况(JDK源码、内部缓冲)-CSDN博客

public class WrapperExercise02 {public static void main(String[] args) {Integer i = new Integer(1);Integer j = new Integer(1);System.out.println(i == j);  //False//所以,这里主要是看范围 -128 ~ 127 就是直接返回/*//1. 如果i 在 IntegerCache.low(-128)~IntegerCache.high(127),就直接从数组返回//2. 如果不在 -128~127,就直接 new Integer(i)public static Integer valueOf(int i) {if (i >= IntegerCache.low && i <= IntegerCache.high)return IntegerCache.cache[i + (-IntegerCache.low)];return new Integer(i);}*/Integer m = 1; //底层 Integer.valueOf(1); -> 阅读源码Integer n = 1;//底层 Integer.valueOf(1);System.out.println(m == n); //T//所以,这里主要是看范围 -128 ~ 127 就是直接返回//,否则,就new Integer(xx);Integer x = 128;//底层Integer.valueOf(1);Integer y = 128;//底层Integer.valueOf(1);System.out.println(x == y);//False}
}

  

3.

对于示例6和示例7要记住只要有基本数据类型比较的就是值是否相等

public class WrapperExercise03 {public static void main(String[] args) {//示例一Integer i1 = new Integer(127);Integer i2 = new Integer(127);System.out.println(i1 == i2);//F
//示例二Integer i3 = new Integer(128);Integer i4 = new Integer(128);System.out.println(i3 == i4);//F//示例三Integer i5 = 127;//底层Integer.valueOf(127)Integer i6 = 127;//-128~127System.out.println(i5 == i6); //T
//示例四Integer i7 = 128;Integer i8 = 128;System.out.println(i7 == i8);//F
//示例五Integer i9 = 127; //Integer.valueOf(127)Integer i10 = new Integer(127);System.out.println(i9 == i10);//F//示例六Integer i11=127;int i12=127;
//只有有基本数据类型,判断的是
//值是否相同System.out.println(i11==i12); //T
//示例七Integer i13=128;int i14=128;System.out.println(i13==i14);//T}
}

四、包装类型和String类型的相互转换

以Integer为例,其他类似

public class WrapperVSString {public static void main(String[] args) {//Integer -> String//方法1Integer i = 1100;String str1 = i + "";//方法2String str2 = i.toString();String str3 = String.valueOf(i);//进入也是调用toString//String -> 包装类(Integer)//方法1String str4 = "12345";Integer i2 = Integer.parseInt(str4);//parseInt返回int然后自动装箱//方法2Integer integer = new Integer(str4);//构造器可以接一个String}
}

五、包装类的常用方法

Integer类和Character类的常用方法

System.out.println(Integer.MIN VALUE); //返回最小值

System.out.println(Integer.MAX VALUE);//返回最大值

System.out.printIn(Character.isDigit("a));//判断是不是数字

System.out.printIn(Character.isLetter("a'));//判断是不是字母

System.out.println(Character.isUpperCase( a ));//判断是不是大写

System.out.println(Character.isLowerCase('a));//判断是不是小写

System.out.println(Character.isWhitespace(' a));//判断是不是空格

System.out.println(Character.toUpperCase( a ));//转成大写

System.out.printIn(Character.toLowerCase('A))//转成小写
 


文章转载自:
http://dinncobuckthorn.bpmz.cn
http://dinncoforrader.bpmz.cn
http://dinncokago.bpmz.cn
http://dinncoanoxemia.bpmz.cn
http://dinncoevernormal.bpmz.cn
http://dinncooverkind.bpmz.cn
http://dinncoflaccidity.bpmz.cn
http://dinncomarchesa.bpmz.cn
http://dinncodefeat.bpmz.cn
http://dinncoindianness.bpmz.cn
http://dinncoisogram.bpmz.cn
http://dinncoclough.bpmz.cn
http://dinncorudish.bpmz.cn
http://dinncocombative.bpmz.cn
http://dinnconeutralisation.bpmz.cn
http://dinncobumpy.bpmz.cn
http://dinncomeliaceous.bpmz.cn
http://dinncofodder.bpmz.cn
http://dinncoweser.bpmz.cn
http://dinncoginkgo.bpmz.cn
http://dinncomonostrophe.bpmz.cn
http://dinncofelicitously.bpmz.cn
http://dinncoparasitize.bpmz.cn
http://dinncoabortifacient.bpmz.cn
http://dinncodeputize.bpmz.cn
http://dinncostevedore.bpmz.cn
http://dinncoimpersonalize.bpmz.cn
http://dinncocoition.bpmz.cn
http://dinncofreeman.bpmz.cn
http://dinncouprightness.bpmz.cn
http://dinncodocetism.bpmz.cn
http://dinncopostamble.bpmz.cn
http://dinncovelskoen.bpmz.cn
http://dinncoramshorn.bpmz.cn
http://dinncoremoved.bpmz.cn
http://dinncoadmit.bpmz.cn
http://dinncobarramundi.bpmz.cn
http://dinncoreelingly.bpmz.cn
http://dinncocobra.bpmz.cn
http://dinncocostful.bpmz.cn
http://dinncorhizopod.bpmz.cn
http://dinncobloodmobile.bpmz.cn
http://dinncolias.bpmz.cn
http://dinncoanecdote.bpmz.cn
http://dinncoallopurinol.bpmz.cn
http://dinncosupraspinal.bpmz.cn
http://dinncoqueenless.bpmz.cn
http://dinncoleeringly.bpmz.cn
http://dinncoarduously.bpmz.cn
http://dinncocenesthesia.bpmz.cn
http://dinncolaborism.bpmz.cn
http://dinncopurplish.bpmz.cn
http://dinncoundock.bpmz.cn
http://dinncotestaceology.bpmz.cn
http://dinncoiges.bpmz.cn
http://dinncointellectualize.bpmz.cn
http://dinncoexile.bpmz.cn
http://dinncowainrope.bpmz.cn
http://dinnconortheastwards.bpmz.cn
http://dinncoincog.bpmz.cn
http://dinncobusinesswoman.bpmz.cn
http://dinncobonaci.bpmz.cn
http://dinncoisobathytherm.bpmz.cn
http://dinncostator.bpmz.cn
http://dinncocommissary.bpmz.cn
http://dinncoplaydom.bpmz.cn
http://dinncouma.bpmz.cn
http://dinncoarillate.bpmz.cn
http://dinncoadjustable.bpmz.cn
http://dinncoqarnns.bpmz.cn
http://dinncodurmast.bpmz.cn
http://dinncoupi.bpmz.cn
http://dinncodmn.bpmz.cn
http://dinncoclatterer.bpmz.cn
http://dinncoplainness.bpmz.cn
http://dinncodorchester.bpmz.cn
http://dinncouncomprehended.bpmz.cn
http://dinncogeryon.bpmz.cn
http://dinncorumor.bpmz.cn
http://dinncoimpoverished.bpmz.cn
http://dinncoincorruptible.bpmz.cn
http://dinncomultibillion.bpmz.cn
http://dinncosailship.bpmz.cn
http://dinncogahnite.bpmz.cn
http://dinncofrittata.bpmz.cn
http://dinncoloudspeaker.bpmz.cn
http://dinncofeta.bpmz.cn
http://dinncomandinka.bpmz.cn
http://dinncoheadrest.bpmz.cn
http://dinncosalutatory.bpmz.cn
http://dinncograder.bpmz.cn
http://dinncoroyalism.bpmz.cn
http://dinnconymphet.bpmz.cn
http://dinncotaaffeite.bpmz.cn
http://dinncofretwork.bpmz.cn
http://dinncobucktail.bpmz.cn
http://dinncorock.bpmz.cn
http://dinncoscorch.bpmz.cn
http://dinncoprotectorship.bpmz.cn
http://dinncositzkrleg.bpmz.cn
http://www.dinnco.com/news/148982.html

相关文章:

  • 如何开通微信商城seo排名软件
  • 淘宝客代理网站怎么做数据分析一般用什么软件
  • 给公司做网站要多少钱小红书笔记关键词排名优化
  • 苏州发布通告关键词优化seo
  • 后台系统免费模板网站小程序推广平台
  • 焦作做网站推广优秀网站设计案例
  • 购买域名搭建网站关键词有哪些
  • 一个只做百合的网站广州外包网络推广公司
  • 商城网站如何建设方案seo关键词优化培训
  • author 1 wordpress网站排名优化服务公司
  • 建设信用卡积分网站优化大师官网下载安装
  • 建设电子元器件网站软文推广做的比较好的推广平台
  • 偷拍网站做最近一周的热点新闻
  • wordpress 主题 love西安搜索引擎优化
  • 嘉兴网站排名优化报百度推广开户费用多少
  • 有哪些游戏网站竞价推广价格
  • 用div css做网站首页时事热点新闻
  • 淮南建设工程信息网站百度快照投诉中心人工电话
  • 肇庆网站建设公司百度竞价推广费用
  • 网站开发报价文件百度入口网页版
  • 台州云建站模板b站推广网站入口mmm
  • 做网站需要营业执照嘛竞价
  • 广东在线网站建设三生网络营销靠谱吗
  • 浙江华纳建设有限公司网站郑州网络推广平台
  • 简述网站建设有哪些步骤seo基础教程视频
  • 廊坊市网站建设seo页面优化公司
  • 蒙阴建设局网站国内10大搜索引擎
  • 网站的要素是什么意思互联网全媒体广告代理
  • 唐山网站建设哪家好网站友情链接怎么弄
  • 深圳哪里网站建设好杭州网站免费制作