equals与==

package com.sxt.jd1803.after.demo;

public class Test {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        String s1 = "abc";
        String s2 = new String("abc");
        System.out.println("s1==s2 :"+(s1==s2));
        
        int i1 = 1;
        Integer i2 =new Integer(1);
        System.out.println("i1==i2: "+(i1==i2));

    }

}
结果:

s1==s2 :false
i1==i2: true

猜你喜欢

转载自blog.csdn.net/qq_36371953/article/details/81113479