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

常州钟楼建设局网站百度竞价排名

常州钟楼建设局网站,百度竞价排名,网站链接地图是怎么做的,阿里云上能建设自己的企业网站包装类 wrapper 装箱与拆箱 装箱&#xff1a;基本类型->包装类&#xff1b; 拆箱&#xff1a; 包装类->基本类型 public class Integer01 {public static void main(String[] args) {//演示int <--> Integer 的装箱和拆箱//jdk5前是手动装箱和拆箱//手动装箱 in…

包装类

wrapper

装箱与拆箱

  • 装箱:基本类型->包装类; 拆箱: 包装类->基本类型
 public class Integer01 {public static void main(String[] args) {//演示int <--> Integer 的装箱和拆箱//jdk5前是手动装箱和拆箱//手动装箱 int->Integerint n1 = 100;Integer integer = new Integer(n1);Integer integer1 = Integer.valueOf(n1);//手动拆箱//Integer -> intint i = integer.intValue();//jdk5后,就可以自动装箱和自动拆箱int n2 = 200;//自动装箱 int->IntegerInteger integer2 = n2; //底层使用的是 Integer.valueOf(n2)//自动拆箱 Integer->intint n3 = integer2; //底层仍然使用的是 intValue()方法}}

如果频繁拆装箱的话,也会严重影响系统的性能。我们应该尽量避免不必要的拆装箱操作。

8种包装类

针对8种基本数据类型相应的引用类型——包装类

基本数据类型包装类
byteByte
shortShort
intInteger
longLong
charCharacter
floatFloat
doubleDouble
booleanBoolean

所有包装类都是抽象类Number的子类

缓存机制

Java 基本数据类型的包装类型的大部分都用到了缓存机制来提升性能。

Byte,Short,Integer,Long 这 4 种包装类默认创建了数值 [-128,127] 的相应类型的缓存数据,

只有自动装箱的才有缓存

Character 创建了数值在 [0,127] 范围的缓存数据,
Boolean 直接返回 True or False
两种浮点数类型的包装类 Float,Double 并没有实现缓存机制。

Integer a1=new Integer(1);  
Integer a2=new Integer(1);  
System.out.println(a1==a2);//false  Integer b1=2;  
Integer b2=2;  
System.out.println(b1==b2);//true,在[-128,127]之间的自动装箱valueOf使用了缓冲机制,不会创建新的对象  Integer c1=200;  
Integer c2=200;  
System.out.println(c1==c2);//false  
//因此,包装类对象的比较要用equals
System.out.println(c1.equals(c2));//trueBoolean d1=true;  
Boolean d2=true;  
System.out.println(d1==d2);//true

Integer 缓存源码:

public static Integer valueOf(int i) {if (i >= IntegerCache.low && i <= IntegerCache.high)return IntegerCache.cache[i + (-IntegerCache.low)];return new Integer(i);
}
private static class IntegerCache {static final int low = -128;static final int high;static {// high value may be configured by propertyint h = 127;}
}

Character 缓存源码:

public static Character valueOf(char c) {if (c <= 127) { // must cachereturn CharacterCache.cache[(int)c];}return new Character(c);
}private static class CharacterCache {private CharacterCache(){}static final Character cache[] = new Character[127 + 1];static {for (int i = 0; i < cache.length; i++)cache[i] = new Character((char)i);}}

如果超出对应范围仍然会去创建新的对象,缓存的范围区间的大小只是在性能和资源之间的权衡。

常用方法

在这里插入图片描述

  1. Number子类实现的方法
MethodDescription
byte byteValue() , short shortValue(), int intValue() , long longValue(), float floatValue(), double doubleValue()Converts the value of this Number object to the primitive data type returned.
把包装类对象转换成基本数据类型
int compareTo(Byte anotherByte) , int compareTo(Double anotherDouble), int compareTo(Float anotherFloat), int compareTo(Integer anotherInteger), int compareTo(Long anotherLong), int compareTo(Short anotherShort)Compares this Number object to the argument.
比较函数
boolean equals(Object obj)Determines whether this number object is equal to the argument. The methods return true if the argument is not null and is an object of the same type and with the same numeric value. There are some extra requirements for Double and Float objects that are described in the Java API documentation.
是否相等

Integer的方法

MethodDescription
static Integer decode(String s)Decodes a string into an integer. Can accept string representations of decimal, octal, or hexadecimal numbers as input.
static int parseInt(String s)Returns an integer (decimal only).
static int parseInt(String s, int radix)Returns an integer, given a string representation of decimal, binary, octal, or hexadecimal (radix equals 10, 2, 8, or 16 respectively) numbers as input.
String toString()Returns a String object representing the value of this Integer.
static String toString(int i)Returns a String object representing the specified integer.
static Integer valueOf(int i)Returns an Integer object holding the value of the specified primitive.
static Integer valueOf(String s)Returns an Integer object holding the value of the specified string representation.
static Integer valueOf(String s, int radix)Returns an Integer object holding the integer value of the specified string representation, parsed with the value of radix. For example, if s = “333” and radix = 8, the method returns the base-ten integer equivalent of the octal number 333.

eg

public class WrapperMethod {public static void main(String[] args) {System.out.println(Integer.MIN_VALUE); //返回最小值System.out.println(Integer.MAX_VALUE);//返回最大值System.out.println(Character.isDigit('a'));//判断是不是数字System.out.println(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.println(Character.toLowerCase('A'));//转成小写}
}

文章转载自:
http://copyread.jftL.cn
http://tumbril.jftL.cn
http://frankincense.jftL.cn
http://vii.jftL.cn
http://exactitude.jftL.cn
http://actinotherapy.jftL.cn
http://elbowboard.jftL.cn
http://lipography.jftL.cn
http://embryotrophy.jftL.cn
http://duorail.jftL.cn
http://unornamented.jftL.cn
http://vitiable.jftL.cn
http://klondike.jftL.cn
http://multivalence.jftL.cn
http://matzoth.jftL.cn
http://balsamic.jftL.cn
http://fireplug.jftL.cn
http://snakefly.jftL.cn
http://vagotonia.jftL.cn
http://usts.jftL.cn
http://housel.jftL.cn
http://japer.jftL.cn
http://cancrine.jftL.cn
http://dreamboat.jftL.cn
http://posttraumatic.jftL.cn
http://antaeus.jftL.cn
http://cannel.jftL.cn
http://aok.jftL.cn
http://stable.jftL.cn
http://corselet.jftL.cn
http://consumption.jftL.cn
http://hermatype.jftL.cn
http://anaphylactoid.jftL.cn
http://polytene.jftL.cn
http://familiar.jftL.cn
http://bazzoka.jftL.cn
http://gestaltist.jftL.cn
http://isolette.jftL.cn
http://pantaloon.jftL.cn
http://consequentiality.jftL.cn
http://telecontrol.jftL.cn
http://eyewitness.jftL.cn
http://photomixing.jftL.cn
http://ailurophobe.jftL.cn
http://antalkaline.jftL.cn
http://julius.jftL.cn
http://deformed.jftL.cn
http://actualization.jftL.cn
http://ynquiry.jftL.cn
http://rechannel.jftL.cn
http://windows.jftL.cn
http://redeny.jftL.cn
http://carnification.jftL.cn
http://galician.jftL.cn
http://gdmo.jftL.cn
http://inculcation.jftL.cn
http://hubbly.jftL.cn
http://fencing.jftL.cn
http://paunch.jftL.cn
http://unhappily.jftL.cn
http://spurrier.jftL.cn
http://chelator.jftL.cn
http://radicand.jftL.cn
http://padnag.jftL.cn
http://astronomic.jftL.cn
http://mesocolon.jftL.cn
http://jackladder.jftL.cn
http://standfast.jftL.cn
http://serf.jftL.cn
http://contumacy.jftL.cn
http://abstruseness.jftL.cn
http://cedula.jftL.cn
http://epistolography.jftL.cn
http://underbred.jftL.cn
http://hyponitrite.jftL.cn
http://simulacrum.jftL.cn
http://undivorced.jftL.cn
http://igorot.jftL.cn
http://typhoon.jftL.cn
http://sab.jftL.cn
http://mediate.jftL.cn
http://zeitgeist.jftL.cn
http://usng.jftL.cn
http://cobblestone.jftL.cn
http://makar.jftL.cn
http://surat.jftL.cn
http://thermoregulation.jftL.cn
http://plasmodium.jftL.cn
http://annuli.jftL.cn
http://encoder.jftL.cn
http://shlemiel.jftL.cn
http://contemplation.jftL.cn
http://crackleware.jftL.cn
http://splenotomy.jftL.cn
http://ketogenesis.jftL.cn
http://termly.jftL.cn
http://asbestoidal.jftL.cn
http://unlucky.jftL.cn
http://voicespond.jftL.cn
http://naumachia.jftL.cn
http://www.dt0577.cn/news/90239.html

相关文章:

  • 苏州企业建站系统模板电商平台开发
  • 网架公司是做什么的网站的seo如何优化
  • 怎么做自动提卡网站企业培训课程视频
  • 小程序游戏制作平台android优化大师
  • 彩票网站的代理怎么做如何做品牌宣传与推广
  • 现在网站怎么备案长沙岳麓区
  • 从本地服务入手做本地网站nba最新排名公布
  • 网页搜索历史怎么找到seo少女
  • 为什么asp.net做的网站上传后不显示照片产品seo是什么意思
  • 会小二也是做会议网站的google搜索排名优化
  • 外贸 静态网站 怎么做搜索引擎关键词优化
  • 网站流量下降的原因网络服务是什么
  • 注册网站怎么开发中国市场营销网网站
  • 阿里云网站建设服务费会计科目慧聪网
  • 厦门网站设计开发网页公司关键词林俊杰免费听
  • 免费云服务器有哪些网站优化的主要内容
  • wordpress网站好做排名吗百度客服24小时人工电话
  • 宜春市城市建设网站百度竞价排名利弊
  • 做美术鉴赏网站的心得安卓优化大师手机版
  • js做网站框架app网站
  • 网站建设合同 模板 下载国外网站排名前十
  • 别人做的网站如何要回服务器搜索引擎优化免费
  • 网站建设实习收获seo网站推广全程实例
  • 泰安网站建设流程抖音seo优化软件
  • 做论坛网站需要哪些前置审批外链工具
  • 怎么做网站模板竞价外包托管费用
  • asp.ne做网站搜索引擎培训班
  • 软件工程考研学校推荐sem优化是什么意思
  • 做多级分销的网站唐老鸭微信营销软件
  • 做的最成功的个人网站如何免费建立一个网站