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

建设银行信用卡积分兑换商城网站ui设计需要学历吗

建设银行信用卡积分兑换商城网站,ui设计需要学历吗,wordpress 最大上传文件大小,怎么更换网站图片文章目录Java中和equals区别1. Integer中和equals的问题1.1 Integer类型且不是通过new创建的比较1.2 手动new Integer()创建的比较1.3 Integer和int比较2. String中和equals的问题3. DemoJava中和equals区别 equals是方法#xff0c;是运算符#xff1a; 如果比较的对象是基… 文章目录Java中和equals区别1. Integer中和equals的问题1.1 Integer类型且不是通过new创建的比较1.2 手动new Integer()创建的比较1.3 Integer和int比较2. String中和equals的问题3. DemoJava中和equals区别 equals是方法是运算符 如果比较的对象是基本数据类型则比较的是数值是否相等如果比较的是引用数据类型则比较的是对象的地址是否相等equals()用来比较两个对象的内容是否相等 注意equals方法不能用于基本数据类型的变量如果没有对equals方法进行重写则比较的是引用类型的变量所指向的对象的地址 1. Integer中和equals的问题 1.1 Integer类型且不是通过new创建的比较 Integer类型且值[-128,127]在这个范围并且不是通过new创建这时候会调用Integer.valueOf()自动装箱方法在这个方法中值[-128,127]在这个范围则会从缓存中去取对象而不是new一个对象否则重新new对象 public static Integer valueOf(int i) {if (i IntegerCache.low i IntegerCache.high)return IntegerCache.cache[i (-IntegerCache.low)];return new Integer(i);}/*** 值位于[-128,127]之间则会从缓存中去取而不是重新new一个对象*/ Integer x 100; Integer y 100; System.out.println(xy);//true/*** 都是Integer并且两者的值不是在[-128127]之间* 这时返回的是重新new出来两个对象因此这两个对象的地址不同故比较的值不同* 要想返回值相同需要使用equals方法*/ Integer a 128; Integer b 128; System.out.println(ab);//false System.out.println(a.equals(b));//true1.2 手动new Integer()创建的比较 手动new Integer()创建对象不走自动装箱机制没有调用Integer.valueOf()方法使用比较的地址是不同的 /*** 自己手动new Integer创建了了两个对象* 不走自动装箱机制没有调用Integer.valueOf()方法,这是两个不同的对象故比较的地址是不同的* 要比较两个值需要使用equals方法*/Integer m new Integer(120);Integer n new Integer(120);System.out.println(mn);//falseSystem.out.println(m.equals(n));//true1.3 Integer和int比较 Integer和int使用比较的是值而不是内存地址 Integer a1 new Integer(110); int a2 110; Integer a3 110; System.out.println(a1a2 is (a1a2));//a1a2 is true System.out.println(a2a3 is (a2a3));//a2a3 is true System.out.println(a1a3 is (a1a3));//a1a3 is false System.out.println(a1.equals(a2) is a1.equals(a2));//a1.equals(a2) is true System.out.println(a3.equals(a2) is a3.equals(a2));//a3.equals(a2) is true System.out.println(a1.equals(a3) is a1.equals(a3));//a1.equals(a3) is true注意 a1是new Integer()创建的对象没有调用Integer.valueOf()自动装箱方法而a3是会调用Integer.valueOf()自动装箱方法从缓存中取到的对象a1a3返回是false。a1.equals(a2)没有问题a2.equals(a1)会报错Cannot resolve method ‘equals(java.lang.Integer)’ 2. String中和equals的问题 String str1 abc; String str2 new String(abc); String str3 abc; String str4 new String(abc);/*** str2和str2不同引用地址*/ System.out.println(str1str2 is (str1str2)); //str1str2 is false/*** str1和str3都在公共池中引用相同*/ System.out.println(str1str3 is (str1str3));//str1str3 is true /*** str2和str4堆中不同引用地址*/ System.out.println(str2str4 is (str2str4));//str2str4 is false System.out.println(str1.equals(str2) is str1.equals(str2));//str1.equals(str2) is true System.out.println(str1.equals(str3) is str1.equals(str3));//str1.equals(str3) is true System.out.println(str2.equals(str4) is str2.equals(str4));//str2.equals(str4) is true3. Demo public class TestEquals {public static void main(String[] args) {//testInteger();testString();}private static void testString() {String str1 abc;String str2 new String(abc);String str3 abc;String str4 new String(abc);/*** str2和str2不同引用地址*/System.out.println(str1str2 is (str1str2)); //str1str2 is false/*** str1和str3都在公共池中引用相同*/System.out.println(str1str3 is (str1str3));//str1str3 is true/*** str2和str4堆中不同引用地址*/System.out.println(str2str4 is (str2str4));//str2str4 is falseSystem.out.println(str1.equals(str2) is str1.equals(str2));//str1.equals(str2) is trueSystem.out.println(str1.equals(str3) is str1.equals(str3));//str1.equals(str3) is trueSystem.out.println(str2.equals(str4) is str2.equals(str4));//str2.equals(str4) is true}private static void testInteger() {/*** 都是Integer且值都在[-128,127]之间,并且不是通过new创建* 值位于[-128,127]之间则会从缓存中去取而不是重新new一个对象*/Integer x 100;Integer y 100;System.out.println(xy);//true/*** 都是Integer并且两者的值不是在[-128127]之间,并且不是通过new创建* 这时返回的是重新new出来两个对象因此这两个对象的地址不同故比较的值不同* 要比较两个值需要使用equals方法*/Integer a 128;Integer b 128;System.out.println(ab);//falseSystem.out.println(a.equals(b));//true/*** 自己手动new Integer创建了了两个对象* 因为手动new所以不走自动装箱机制没有调用Integer.valueOf()方法,这是两个不同的对象故比较的地址是不同的* 要比较两个值需要使用equals方法*/Integer m new Integer(120);Integer n new Integer(120);System.out.println(mn);//falseSystem.out.println(m.equals(n));//trueInteger a1 new Integer(110);int a2 110;Integer a3 110;System.out.println(a1a2 is (a1a2));//a1a2 is trueSystem.out.println(a2a3 is (a2a3));//a2a3 is trueSystem.out.println(a1a3 is (a1a3));//a1a3 is falseSystem.out.println(a1.equals(a2) is a1.equals(a2));//a1.equals(a2) is trueSystem.out.println(a3.equals(a2) is a3.equals(a2));//a3.equals(a2) is trueSystem.out.println(a1.equals(a3) is a1.equals(a3));//a1.equals(a3) is true} }
http://www.hkea.cn/news/14457270/

相关文章:

  • 开发app找什么公司seo排名技巧
  • 怎么在网上卖东西给外国人台州做优化
  • 西宁网站建设哪家强如何设计旅游网站
  • 网站做关键词库的作用广州环保网站建设
  • phpnow 新建网站莆田高端模板建站
  • 诸城网站建设公司排名图片制作器app
  • 成都便宜网站建设公司哪家好专业的企业网站建设
  • 海事网站开发包头网络推广
  • 邦邻网站建设网站开发采用了哪些技术怎么写
  • 范湖网站建设哪家便宜昆明网络关键词排名
  • 广西建网站哪家好网页设计如何制作背景
  • 网站建设与维护 计算机乐清网络公司哪家最好
  • 郑州网站建设蝶动科技wordpress支持七牛
  • 企业网站建设 招标 评分表深圳网站建设企业名录
  • 免费网站是上海景观设计公司排行
  • 网站开发php学校内蒙古呼和浩特天气预报
  • 公司注册网站官网网站备案服务商查询
  • 宁波网站建设制作公司哪家好儿童衣服刘涛做代言那个是什么网站
  • 网站建设与管理学的是什么soho个人可以建网站吗
  • 有云服务器怎么做网站建立个机密网站
  • 浮动微信代码wordpress英文网站seo方案
  • 十堰网站seo方法荥阳网页设计
  • 做点心的网站网站如何添加友情链接
  • 邵阳网站建设推广京东上怎样做网站
  • 如何建设cf提卡网站黄桃图片友情链接
  • 网站建设公司杭州18年加强网站安全建设方案
  • 网站建设费属于什么税目wordpress 公开显示为
  • 商城网站有免费建设的吗网站右侧二维码代码
  • 网站集约化建设方案跟我一起学做网站
  • 大同哪有做网站的轻奢风格装修图片