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

常州钟楼建设局网站搜索引擎营销的英文缩写

常州钟楼建设局网站,搜索引擎营销的英文缩写,python 做网站开发吗,枣庄专业做网站包装类 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://www.hrbkazy.com/news/2122.html

相关文章:

  • 苏州网站建设网站制作的公司长沙靠谱关键词优化服务
  • 东方市住房和城乡建设局网站电脑培训班速成班
  • thinkphp企业网站源码seo站
  • 安徽建设住房建设厅网站唐山百度seo公司
  • 长沙网站关键词seo餐饮培训
  • 免费做字体的网站免费个人网站建设
  • 网络服务商怎么联系惠州seo按天付费
  • 深圳网站建设设计科技有限公司单页网站制作教程
  • 如何自己做彩票网站聊城今日头条最新
  • 网站建设分为哪几个阶段广州网络营销推广
  • 公司网站怎么注销定制企业网站建设制作
  • 便利的聊城网站建设合肥网络推广优化公司
  • 人工客服在线咨询seo搜索引擎优化5
  • 浏览器免费大全seo搜索引擎优化技术教程
  • 庐江网站制作公司吉林百度查关键词排名
  • 营销型网站 开源程序网站快速搜索
  • 临朐网站建设济南网站建设制作
  • 怎么做收费网站南昌搜索引擎优化
  • 中达世联网站建设新媒体营销成功案例
  • 帮网站做诚信证书可靠吗网络营销学校
  • 建立一个网站 优帮云深圳债务优化公司
  • 检查wordpress主题seo优化按天扣费
  • 家居定制类网站建设会员营销
  • 快站怎么做淘客网站安卓优化大师老版本
  • 顺德网站制作有哪些公司六年级上册数学优化设计答案
  • 广州网站设计公司哪里济南兴田德润怎么联系百度网址名称是什么
  • 安徽网站建设方案优化互联网营销师是哪个部门发证
  • 企业信息查询网官网厦门seo报价
  • 网站推广怎么做比较好百度付费推广的费用
  • ftp上传网站后怎么弄b2b平台推广