zoukankan      html  css  js  c++  java
  • Java 中的 ==

    简介

    如果没有重写 equals 方法, 相当于 == 比较, 即比较两个对象的地址是否相等.

    如果是基本数据类型, 直接对值进行比较.

    code

    /**
     * Created by lee on 2021/6/28.
     */
    public class equalTest {
        public static void main(String[] args) {
            System.out.println(1 == 1);
            System.out.println(1 == 2);
            System.out.println(159 == 159);
            Person1 a = new Person1(1);
            Person1 b = new Person1(1);
            System.out.println(a == b);
            Integer c = new Integer(100);
            Integer d = new Integer(100);
            System.out.println(c == d);
            int e = 1;
            int f = 1;
            System.out.println(e == f);
            Integer g = 200;
            Integer h = 200;
            System.out.println(g == h);
            int g1 = 200;
            int h1 = 200;
            System.out.println(g1 == h1);
        }
    }
    
    

    answer

    true
    false
    true
    false
    false
    true
    false
    true
    
    Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
  • 相关阅读:
    HyperV创建NAT网络
    Win10
    ConEmu
    ffmpeg的centos、msys2、msvc编译
    7z压缩gopath的src的批处理
    VS2015自带v120的Platform Toolset
    Putty配置
    第一章:HTML5的基础
    java的错题整理
    第十四章:类的带参方法
  • 原文地址:https://www.cnblogs.com/eat-too-much/p/14945123.html
Copyright © 2011-2022 走看看