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

河北网站制作 网站开发四种基本营销模式

河北网站制作 网站开发,四种基本营销模式,沧州网站建设,中国网络营销公司排名一、包装类 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://www.hrbkazy.com/news/56385.html

相关文章:

  • 公司手机网站开发招标书免费b2b平台推广
  • 阿里巴巴的网站应该怎么做石家庄网站建设就找
  • wordpress+4.5+多站点西安seo技术
  • 2023年企业年报入口网站网页的优化方法
  • 简单的公司资料网站怎么做惠州seo优化
  • 拓者设计吧会员有啥区别宁波seo网络推广产品服务
  • 博客网站开发视频广告网络推广怎么做
  • 专业长春网站建设网百度的网页地址
  • 内乡微网站开发中小企业网络营销现状
  • 机械加工类网站怎么做上海网络推广招聘
  • dedecms招聘网站优化课程设置
  • 手机网站 生成app智能建站网站模板
  • 沈阳做网站费用对网络营销的理解
  • 衡水做网站服务商精准引流怎么推广
  • 怎么把自己做的网站网页制作软件哪个好
  • 蛋糕教做网站搜索引擎优化的步骤
  • 网站为什么提示风险汕头seo服务
  • 哪里可以做免费网站爱站网关键词搜索
  • 专业建站工作室seo助力网站转化率提升
  • 一个网站绑定多个域名百度图片识别在线使用
  • 网站的推广方式组合seo上首页
  • 小程序网站建设百度seo关键词优化工具
  • 旅游网站建设与翻译南宁seo收费
  • 自己做的网站图片打开慢网络营销策略分析报告
  • 海南最新疫情今天新增推广学院seo教程
  • 长沙哪里做网站价格便宜公司推广咨询
  • 甘肃网站建设费用seo网站诊断文档案例
  • wordpress 建站 教程视频网销怎么做才能做好
  • wordpress指定文章p=天津百度网站快速优化
  • 织梦pc怎么做手机网站百度图片识别搜索