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

嘉峪关市网站建设设计360提交网站收录入口

嘉峪关市网站建设设计,360提交网站收录入口,正规公司代办,苹果电脑做网站设计【1】Java.lang直接使用&#xff0c;无需导包&#xff1a; 【2】类的继承关系&#xff1a; 【3】实现接口&#xff1a; Serializable&#xff0c;Comparable<Integer> 【4】这个类被final修饰&#xff0c;那么这个类不能有子类&#xff0c;不能被继承&#xff1a; 【5】…

【1】Java.lang直接使用,无需导包:

【2】类的继承关系:

【3】实现接口:

Serializable,Comparable<Integer>

【4】这个类被final修饰,那么这个类不能有子类,不能被继承

【5】包装类是对基本数据类型的封装: 对int类型封装产生了Integer

【6】类的历史: 从JDK1.0开始

【7】属性:

//属性:
System.out.println(Integer.MAX_VALUE);
System.out.println(Integer.MIN_VALUE);
//“物极必反”原理:
System.out.println(Integer.MAX_VALUE+1);
System.out.println(Integer.MIN_VALUE-1);

【8】构造器(发现没有空参构造器)

(1)int类型作为构造器的参数:

Integer i1 = new Integer(12);

(2)String类型作为构造器的参数:

Integer i2 = new Integer("12");
Integer i3 = new Integer("abcdef");

 

【9】包装类特有的机制:自动装箱  自动拆箱:

    //自动装箱:int--->IntegerInteger i = 12;System.out.println(i);//自动拆箱:Integer--->intInteger i2 = new Integer(12);int num = i2;System.out.println(num);

(1)自动装箱  自动拆箱 是从JDK1.5以后新出的特性

(2)自动装箱  自动拆箱 :将基本数据类型和包装类进行快速的类型转换。

验证:

可以自定打断点测试是否走入valueOf方法中:

valueOf转换成为Integer

注意:

如果值为-128到127之间,则不转换成为Integer,保存在一个cache数组中。

 如果自动装箱值在-128~127之间,那么比较的就是具体的数值否则,比较的就是对象的地址

IntValue转换成为int

【10】常用方法:

valueOf方法的底层:

package com.mytest;/*** @Auther: gotsgo*/
public class Test04 {//这是一个main方法,是程序的入口:public static void main(String[] args) {//compareTo:只返回三个值:要么是0,-1,1Integer i1 = new Integer(6);Integer i2 = new Integer(12);System.out.println(i1.compareTo(i2));// return (x < y) ? -1 : ((x == y) ? 0 : 1);//equals:Integer对Object中的equals方法进行了重写,比较的是底层封装的那个value的值。//Integer对象是通过new关键字创建的对象:Integer i3 = new Integer(12);Integer i4 = new Integer(12);System.out.println(i3 == i4);//false 因为==比较的是两个对象的地址boolean flag = i3.equals(i4);System.out.println(flag);//Integer对象通过自动装箱来完成:Integer i5 = 130;Integer i6 = 130;System.out.println(i5.equals(i6));//trueSystem.out.println(i5 == i6);/*如果自动装箱值在-128~127之间,那么比较的就是具体的数值否则,比较的就是对象的地址*///intValue() :作用将Integer--->intInteger i7 = 130;int i = i7.intValue();System.out.println(i);//parseInt(String s) :String--->int:int i8 = Integer.parseInt("12");System.out.println(i8);//toString:Integer--->StringInteger i10 = 130;System.out.println(i10.toString());}
}

http://www.ritt.cn/news/25479.html

相关文章:

  • 建设个人网站需要多少钱活动营销方案
  • 红酒公司网站建设模板6841网站制作推广电话
  • 北师大 网页制作与网站建设 考试西地那非片
  • 推广做网站多少钱北京疫情最新消息
  • 做域名代理网站股票发行ipo和seo是什么意思
  • 设计本和游戏本的区别seo首页排名优化
  • 莱西网站建设百度网站推广教程
  • 网站模板库软件深圳网络推广最新招聘
  • 手机搭建wordpressseo推广视频隐迅推专业
  • 瑞安公司做网站互联网营销师考试内容
  • 安阳专业网站建设附近的成人电脑培训班
  • 是做网站设计好还是杂志美编好东莞seoseo关键词排名优化
  • 网站建设公司dyfwzx环球军事网最新军事新闻最新消息
  • 网站建设费会计处理网站优化排名哪家性价比高
  • pc端网站国际羽联最新排名
  • 广州化妆品网站建设公司排名网络营销专业是干嘛的
  • 做外链音乐网站福州seo按天收费
  • 网站制作者站长工具亚洲
  • 广东深圳旅游景点建站合肥网络公司seo
  • 济南做门户网站开发公司站内优化包括哪些
  • 找人网站 优帮云小程序seo
  • 复制文章中自动添加网站版权新网站如何让百度收录
  • 设计网站公司哪里好河南郑州最新消息今天
  • 命令行安装wordpress安徽网络seo
  • 源码屋整站源码线上推广外包公司
  • 电商网站 magento班级优化大师电脑版
  • wordpress 2 s关键词快速排名seo怎么优化
  • cms做的网站胡源代码谷歌搜索引擎免费入口 香港
  • 网站开发后期做什么郑州seo优化顾问热狗
  • 昆山网站设计哪家好守游网络推广平台登陆