zoukankan      html  css  js  c++  java
  • Chapter 4 : Control Structures 1 : Selection


    Although it need not be, the expression is usually an identifier. Whether it is an identifier
    or an expression, the value of the identifier or the expression can only be of type int, byte, short,
    or char

    public class StringComapre {
        
        public static void main(String[] args) {    
        
        String    str1 = new String("Hello");
        String    str2 = "Hello";
        
        if (str1 == str2)
            System.out.println("str1 equal str2");
        else
            System.out.println("str1 != str2");
        
        ////////////////////////////////////////////////////////
        
        String    str3 = "Hello";
        String    str4 = new String("Hello");
        
        if (str3 == str4)
            System.out.println("str3 equal str4");
        else
            System.out.println("str3 != str4");
        
        ///////////////////////////////////////////////////////
        
        String    str5 = new String("Hello");
        String    str6 = new String("Hello");
        
        if (str5 == str6)
            System.out.println("str5 equal str6");
        else
            System.out.println("str5 != str6");
        
        }
    }

      这段代码有疑问,为什么str1 和 str2不相等?

  • 相关阅读:
    Redis内存回收策略
    7、IMS
    6、端局、汇接局、关口局、长途局
    5、IMS网元
    4、IMS
    3、NAT
    2、SIP
    1、B2BUA
    九、数据库——sql server 2008导入excel
    六十三、android pad
  • 原文地址:https://www.cnblogs.com/hare/p/4103321.html
Copyright © 2011-2022 走看看