zoukankan      html  css  js  c++  java
  • equals 和 ==

    //==比较引用,equals比较值
    //new string("")会创建两个对象



    boolean b = "发".equals("发");
    System.out.println("发"=="发");//true
    System.out.println(new String("发")==new String("发"));//false
    System.out.println(new Integer(1).equals(new Integer(1)));//true
    System.out.println(new Integer(1)==new Integer(1));//false


    /*Integer a = 1;//在-128和127之间直接从IntegerCache中取,不会创建新对象
    Integer c = 1;
    System.out.println(a==c);//true
    System.out.println(a.equals(c));//true */

    /*Integer a = 1000;
    Integer c = 1000;
    System.out.println(a==c);//false
    System.out.println(a.equals(c));//true */

    Integer a = new Integer(1000);
    Integer c = new Integer(1000);
    System.out.println(a==c); //false
    System.out.println(a.equals(c)); //ture

    Boolean b1 = true;
    Boolean b2 = true;
    System.out.println(b1==b2);

  • 相关阅读:
    CSS学习1
    三个和尚没水喝阅读笔记
    Javascript学习1

    mv 批量
    emacs 大小写转换
    too many open files
    成都定房
    有关重定向
    postgresql 数据库
  • 原文地址:https://www.cnblogs.com/xiaolbk/p/6898166.html
Copyright © 2011-2022 走看看