zoukankan      html  css  js  c++  java
  • 包装类

    import java.io.File;
    import java.io.FileReader;
    
    /**
     * 包装类
     * 详解:http://alexyyek.github.io/2014/12/29/wrapperClass/
     */
    public class WrappClassTest {
        public static void main(String[] args) {
            Integer a = 1;
            Integer b = 2;
            Integer c = 3;
            Integer d = 3;
            Integer e = 200;
            Integer f = 200;
            Long g = 3L;
            Long h = 2L;
    
            System.out.println("c == d -> " + (c == d));
            System.out.println("e == f -> " + (e == f));
            System.out.println("c == (a + b) -> " + (c == (a + b)));
            System.out.println("c.equals(a + b) -> " + (c.equals(a + b)));
            System.out.println("g == (a + b) -> " + (g == (a + b)));
            System.out.println("g.equals(a + b) -> " + (g.equals(a + b)));
            System.out.println("g.equals(a + h) -> " + (g.equals(a + h)));
    
    
            String s1 = "ab";
            String s2 = "a" + "b";
            String s4 = new String("ab");
            String s5 = new String("ab");
            String str1 = "a";
            String str2 = "b";
    
            String s3 = str1 + str2;
            System.out.println(s1 == s2);
            System.out.println(s1 == s3);
            System.out.println(s3);
            System.out.println(s1 == s4);
            System.out.println(s5 == s4);
            System.out.println(s5.equals(s4));
            System.out.println(s5.hashCode() == s4.hashCode());
    
    
        }
    }

    结果

    c == d -> true
    e == f -> false
    c == (a + b) -> true
    c.equals(a + b) -> true
    g == (a + b) -> true
    g.equals(a + b) -> false
    g.equals(a + h) -> true
    true
    false
    ab
    false
    false
    true
    true
  • 相关阅读:
    centos7安装KVM
    keepalived高可用
    Jenkins-Pipeline 流水线发布部署项目
    centos7部署jenkins
    版本控制gitlab
    c语言寻找3000以内亲密数对
    c语言寻找1000以内的完全数
    c语言分解因式
    c语言判断给定日期是当年的第几天
    c语言计算程序运行时间
  • 原文地址:https://www.cnblogs.com/dayaodao/p/8697136.html
Copyright © 2011-2022 走看看